Information Technology Reference
In-Depth Information
When listing branches with
$ git branch
you can use the additional parameter
-v
. The command
$ git branch -v
will print the latest revision in every branch,
for example:
* doc 23d9855 d3
info 0d6501b i3
master 7c9bc41 m3
Finish the recipe executing the two commands:
$ git checkout master
$ git pack-refs --all
The first of them will change the current branch to the
master
while the second
will store the all the references, including all the branches, in a file named
.git/
packed-refs
.
How It Works
Every repository contains the special file
.git/HEAD
, which points to the current re-
vision. That's how git knows which revision you recently checked out. This is also
used as a parent revision during your next commit. The reference stored in
.git/
HEAD
file is written in one of two forms:
• As a symbolic reference to the branch
• As a SHA-1
If you are on a branch then the contents of
.git/HEAD
is written in symbolic
form. When you enter the detached HEAD state the reference is written as SHA-1.
Here, we will focus on symbolic references. SHA-1 references will be discussed in Re-
cipe 5-4.
The symbolic form of the reference looks like this:
ref: refs/heads/master