Rebase
As we just saw, the merge
command combines the changes from two branches. The rebase
command will take the changes from the first branch and apply them to the other branch.
In the rebase
command do not merge commit!
The following diagram displays the current state of our repository. We have the master branch pointed on Commit 3 and a branch pointed to Commit 4:
Our goal is to rebase
branch from master, so we need to checkout
on master and rebase
it:
Erik@local:~/webproject$ git checkout branch Erik@local:~/webproject$ git rebase master
The rebase
command can be used if you want to get a feature (commits) from one branch to another and be sure ...
Get Git Best Practices Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.