Information Technology Reference
In-Depth Information
How It Works
This recipe explains how you can create many divergent branches. We only use com-
mands already quite well-known to achieve this:
clone
,
checkout
, and
simple-
commit
. That's how you can easily generate a repository with a given structure. This
capability is very useful, in case you want to analyze a git command and the impact it
has on the graph's structure.
Keep in mind that when you use the
$ git log
command with
--graph
option
the drawing you get can be a little different. The result of
$ git log --oneline
--graph --decorate --all
for a repository from
Figure 7-8(b)
is shown in
Figure 7-9
.
The repository from
Figure 7-8(b)
as drawn by $ git log --oneline --graph --decorate --all
Once you create the repository shown in
Figure 7-8
, many questions regarding the
graph of revisions may arise. Such as the following:
• How to find a common ancestor of branches
a
and
b
?
• How to find a common ancestor of arbitrary number of branches?