The branch object is not really like any other Git objects; you can't print it using the cat-file command as we can with the others (if you specify the -p pretty print, you'll just get the commit object it points to), as shown in the following code:
$ git cat-file master usage: git cat-file (-t|-s|-e|-p|<type>|--textconv) <object> or: git cat-file (--batch|--batch-check) < <list_of_objects> <type> can be one of: blob, tree, commit, tag. ... $ git cat-file -p master tree 34fa038544bcd9aed660c08320214bafff94150b parent a90d1906337a6d75f1dc32da647931f932500d83 ...
Instead, we can take a look at the branch inside the .git folder where the whole Git repository is stored. If we open the text file .git/refs/heads/master, we can actually see the commit ID that the master branch points to. We can do this using cat, as follows:
$ cat .git/refs/heads/master 13dcada077e446d3a05ea9cdbc8ecc261a94e42d
We can verify that this is the latest commit by running git log -1:
$ git log -1 commit 34acc370b4d6ae53f051255680feaefaf7f7850d (HEAD -> master, origin/master, origin/HEAD) Author: John Doe <[email protected]> Date: Fri Dec 13 12:26:00 2013 +0100 This is the subject line of the commit message ...
We can also see that HEAD is pointing to the active branch by using cat with the .git/HEAD file:
$ cat .git/HEAD ref: refs/heads/master
The branch object is simply a pointer to a commit, identified by its SHA-1 hash.