How to rebase local branch with remote master

后端 未结 7 1292
北海茫月
北海茫月 2020-11-28 17:03

I have a cloned project from a master branch from remote repository remote_repo. I create a new branch and I commit to that branch. Other programmers pushed to

7条回答
  •  无人及你
    2020-11-28 17:39

    After committing changes to your branch, checkout master and pull it to get its latest changes from the repo:

    git checkout master
    git pull origin master
    

    Then checkout your branch and rebase your changes on master:

    git checkout RB
    git rebase master
    

    ...or last two commands in one line:

    git rebase master RB
    

    When trying to push back to origin/RB, you'll probably get an error; if you're the only one working on RB, you can force push:

    git push --force origin RB
    

    ...or as follows if you have git configured appropriately:

    git push -f
    

提交回复
热议问题