Information Technology Reference
In-Depth Information
Figure 7-3
.
More exact rebasing copies of revisions f1, f2, and f3 into another branch—original revisions are left
intact
The
Figure 7-3
contains a hint on how to recover from rebasing. To undo rebasing
all you have to do is to change the revision that is pointed to by the
feature
branch.
You should remember from the previous chapter that branches are just pointers. You
can treat them as stickers: everything can be unstuck from one place and then stuck
again in another location. This operation does not modify the database—all revisions
remain intact. If you modify the
feature
branch in such a way that it points to the
f3
revision again, the rebasing will be undone.
Let's find the original revision
f3
. As always—you can use the
$ git reflog
command. But this time its output can be misleading. Probably it will be easier to ex-
plore reflog with the
$ git log
command. We want to get the list of all the commits
that:
• Are included in reflog
• Have comments containing
f3
string
The appropriate command is presented in
Listing 7-1
.
The format defined with the
-
-pretty
parameter prints shortened hashes (
%h
placeholder), comments (
%s
place-
holder), and commit dates (
%cd
placeholder). Every commit can appear in reflog many
times. Actually, every checkout will store a new reference to the commit in reflog.