Information Technology Reference
In-Depth Information
Figure 5-14
.
Using HEAD with the ancestor references for the branch named info
Have you noticed the asterisk in front of
*info
branch name? As I told you: this is
a much easier way to show which branch you are currently on. The asterisk informs
you that
.git/HEAD
now contains the
ref: refs/heads/info
symbolic refer-
ence. This idea is not mineāit is taken from the output of the
$ git branch
com-
mand that would now be:
doc
* info
master
Maybe you noticed that the command
$ git checkout [REVISION]
works
differently depending on its parameter. If the parameter is a SHA-1 name, then the
command enters detached HEAD state. If, on the other hand, you pass a branch name,
the command will change your current branch. You can force the detached HEAD state
with a
--detached
option, for example
$ git checkout --detached mas-
ter
.
The above rules apply even if you pass the SHA-1 of the commit pointed to by a
branch. Assuming that
$ git log --oneline --decorate
prints:
7c9bc41 (HEAD, master) m3
the command: