Information Technology Reference
In-Depth Information
Figure 6-9
.
Alternative visual representation of the repository shown in
Figure 6-8
Solution
Clone the repository from Recipe 6-4 with branches:
$ cd git-recipes
$ git clone-with-branches 06-04 06-05
$ cd 06-05
and merge branches with the
$ git merge feature
command.
How It Works
In cases where fast-forward is not possible the
$ git merge
command creates an
additional revision, called
merge commit
. This commit differs from the commits you
have created so far because it contains more than one parent. It joins two or more dif-
ferent revisions. This gives us the opportunity to classify every commit as either a
non-
merge commit
or a
merge commit
. A
merge commit
is a commit that has two or
more parents. A
non-merge commit
is a commit with exactly one parent. Obviously,
the commit created in this recipe has two parents thus it a merge commit.
When inspecting the history with
$ git log
or
$ gitk
, you can filter out both
types of commits. The command:
$ git log --oneline --merges