How to rebase local branch with remote master

I have cloned project from master branch from remote repository remote_repo . I create new branch and I commit to that branch. Other programmers pushed to remote_repo to master branch. I need now to rebase my branch RB onto remote_repo master. How to do this ? What commands to type to terminal ?


First fetch the new master from the upstream repository, then rebase your work branch on that:

git fetch origin            # Updates origin/master
git rebase origin/master    # Rebases current branch onto origin/master

Update: Please see Paul Draper's answer for a more concise way to do the same - recent Git versions provide a simpler way to do the equivalent of the above two commands.


 git pull --rebase origin master

After changes committed to your branch, checkout master and pull to get the 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
链接地址: http://www.djcxy.com/p/4038.html

上一篇: 你能解释一下“git reset”在纯英文中的含义吗?

下一篇: 如何用远程主人重新绑定本地分支