Information Technology Reference
In-Depth Information
Solution
Create a new repository containing revisions
a
through
f
:
$ cd git-recipes
$ git init 08-06
$ cd 08-06
$ git simple-commit a b c d e f
The
$ git log --oneline
command now prints the revisions in the following
order:
35cba5a
f
4932572
e
bb7f037
d
93b7397
c
9219566
b
17e5231
a
You want to remove some commits from the history. The oldest commit you want to
remove is
b
. It is fifth commit in the history (
f
is the first,
e
is the second,
d
is the
third,
c
is the fourth, and
b
is the fifth). The command you need is
$ git rebase
-i HEAD
∼
5
. It is interactive rebasing so git will start the editor. The original subcom-
mands of interactive rebasing are shown in in
Listing 8-7
.
Replace them with the sub-
commands shown in
Listing 8-8
. Finally save the file and close the editor.
Listing 8-7.
The original subcommands of interactive rebasing in Recipe 8-6
pick 9219566 b
pick 93b7397 c
pick bb7f037 d
pick 4932572 e
pick 35cba5a f
Listing 8-8.
The commands that perform the transformation shown in
Figure 8-6
pick 93b7397 c
pick 4932572 e