Here's how rebase works:
git checkout <my branch>
git rebase master
git checkout master
git merge <my branch>
Assume you have
---o----o----o----o master
\---A----B <my branch>
The first two commands ...
commit
git checkout
git rebase master
... check out the branch of changes you want to apply to the master branch. The rebase command takes the commits from <my branch> (that are not found in master) and reapplies them to the head of master. In other words, the parent of the first commit in <my branch> is no longer a previous commit in the master history, but the current head of master. The two commands are the same as:
git rebase master <my branch>
It might be easier to remember this command as both the "base" and "modify" branches are explicit.
. The final history result is:
---o----o----o----o master
\----A'----B' <my branch>
The final two commands ...
git checkout master
git merge <my branch>
... do a fast-forward merge to apply all <my branch> changes onto master. Without this step, the rebase commit does not get added to master. The final result is:
---o----o----o----o----A'----B' master, <my branch>
master and <my branch> both reference B'. Also, from this point it is safe to delete the <my branch> reference.
git branch -d <my branch>
--cachedwhen checkinggit diff. link