Information Technology Reference
In-Depth Information
The main drawback of the above solution is that here you have to know which revi-
sions you want to reapply. The command
$ git format-patch
takes this burden
off of your shoulders! Also
$ git cherry-pick
doesn't create patches. To email
patches you will have to generate them with the
$ git format-patch
command.
Hint
The main reason behind Recipe 7-2 is to provide you with deeper understand-
ing how
$ git rebase
works. Do not rebase your branches using
$ git
format-patch
,
$ git am
, or
$ git cherry-pick
unless you want to email
patches to someone else. Use the
$ git rebase
command instead. The analysis in-
cluded in Recipe 7-2 will help you to understand the internals of rebasing. Depending
on your workflow, rebasing may be necessary every time you want to publish your
work.
7-3. Joining divergent branches into lin-
ear history
Problem
You work in a repository with two divergent branches named
master
and
feature
,
branch in such a way that the resulting history is linear, that is, it doesn't contain merge
commits. The starting point for this recipe is shown in
Figure 7-7(a)
.
The repository
you want to obtain is presented in
Figure 7-7(b)
.