Information Technology Reference
In-Depth Information
Figure 8-1
.
Removing two most recent revisions
Solution
Create a new repository containing revisions
a
,
b
,
c
, and
d
:
$ cd git-recipes
$ git init 08-02
$ cd 08-02
$ git simple-commit a b c d
Your repository now contains four revisions. All of them are included in the
mas-
ter
branch. To remove the two most recent revisions use the command
$ git re-
set --hard HEAD
∼
2
. Now the
$ git log --oneline
command returns only
two revisions: a and b. Revisions c and d are removed from the history.
Hint
You can use this recipe to remove any number of most recent commits. The
command
$ git reset --hard HEAD
∼
13
will remove the last 13 commits.
How It Works
SHA-1 of the revision
b
to achieve the same result. Assuming that the name of revision
b
is
a1b2c3d4
the following commands are equivalent: