How to rebase local branch with remote master

Damir picture Damir · Oct 28, 2011 · Viewed 909.5k times · Source

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 remote_repo to the master branch.

I need now to rebase my branch RB onto remote_repo master.

How to do this? What commands to type to a terminal?

Answer

Frerich Raabe picture Frerich Raabe · Oct 28, 2011

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.