Information Technology Reference
In-Depth Information
$ git checkout feature
$ git merge master
will only print a short info:
Already up-to-date
. The repository doesn't
change.
6-3. Undoing fast-forward
Problem
You have completed the fast-forward operation presented in Recipe 6-2, and you are
not satisfied with it. You want to undo the merge. In other words, you want to trans-
form the repository shown in
Figure 6-4
back into the form presented in
Figure 6-2
.
Solution
Clone the repository
06-02
with the
cp
command:
$ cd git-recipes
$ cp -R 06-02 06-03
$ cd 06-03
The easiest solution to undo merging is to use reflog. Thanks to using the
cp
com-
mand for cloning the reflog is not empty, as it would have been if you had used the
$
git clone
command. The command
$ git reflog
prints the results similar to:
0deae94 HEAD@{0}: merge feature: Fast-forward
757d501 HEAD@{1}: checkout: moving from feature to master
0deae94 HEAD@{2}: checkout: moving from feature to feature
0deae94 HEAD@{3}: clone: from c:/git-recipes/06-01
You can undo the merge using
$ git reset --hard HEAD@{1}
.
How It Works