Information Technology Reference
In-Depth Information
8-8. Reverting revisions
Problem
Your repository contains any number of revisions. One of the commits introduced a
bug in your project. You want to undo the changes introduced by this commit in such a
way that the history of the project up to the current HEAD remains unchanged.
The transformation you want to achieve is presented in
Figure 8-8
. The revision
labeled with
b
should be reverted. The history up to the revision
c
has to remain un-
changed. The operation will be realized by the creation of an additional revision
labeled
Revert "b"
. This new commit reverts the changes introduced by
b
.
Figure 8-8
.
Reverting revisions
Solution
Create a new repository containing revisions
a
,
b
,
c
:
$ cd git-recipes
$ git init 08-08
$ cd 08-08
$ git simple-commit a b c
and then execute the
$ git revert --no-edit HEAD
∼
command.
How It Works