To illustrate rebasing we consider the following situation - we wish to merge
master
into devel
:
Now you know how to do it:
$ git checkout devel
$ git merge master
This creates a merge commit:
But there is an alternative for integrating master
commits into the devel
branch:
$ git checkout devel
$ git rebase master
git rebase
replays the branch commits b1
to b3
on top of master
.c5
.b1
to b3
have been replaced by b1*
to b3*
).git rebase
makes “merges” producing a linear history.git merge
resolves all conflicts in a single commit, with git rebase
each commit may need
conflict resolution.git rebase
may invalidate tests.git merge
preserves chronology of commits and creates explicit merge commits (unless fast-forward).git rebase
can change chronology of commits.
Rebasing creates nice linear history without merge commits, but is associated with potential risks.