Information Technology Reference
In-Depth Information
Hint
You should treat this recipe as another warning: do not work in a detached
HEAD state. You can easily avoid it by using branches.
How It Works
The first problem we have to resolve is how to refer to the revision labeled as
i1
. Sure,
you can find its full or abbreviated name using the
$ git log
or
$ git log --
oneline
command. You should be quite familiar with these methods of referring to
commits already. In this recipe, however, we used ancestor references—yet another
very convenient method to identify revisions.
Every revision except the very first one contains a parent. We can refer to the parent
revision using the tilde (
∼
) sign. The notation
[REVISION]
∼
denotes the parent of a
given revision. You can use this notation in conjunction with any method to identify a
revision. You can write:
7c9bc41684455b2b38749ec9cdeed707c07038b2
∼
7c9b
∼
master
∼
info
∼
HEAD
∼
The notation:
7c9bc41684455b2b38749ec9cdeed707c07038b2
∼
refers to the parent revision of the revision pointed to by
7c9b-
c41684455b2b38749ec9cdeed707c07038b2
. The next reference,
7c9b
∼
,
points to the same revision using a shortened name. In a similar way:
•
master
∼
refers to the parent of the commit pointed to by
master
branch
•
info
∼
points to the parent of the commit pointed to by
info
branch
•
HEAD
∼
refers to the parent of the current revision
• and so forth