tags:

views:

1701

answers:

2

You see the Git documentation saying things like "The branch must be fully merged in HEAD".

But what is Git HEAD, exactly?

+13  A: 

You can think of the HEAD as the "current branch". When you switch branches with git checkout, the HEAD revision changes to point to the tip of the new branch.

You can see what HEAD points to by doing:

cat .git/HEAD

In my case, the output is:

$ cat .git/HEAD
ref: refs/heads/master

It is possible for HEAD to refer to a specific revision that is not associated with a branch name. This situation is called a detached HEAD.

Greg Hewgill
So git HEAD is context dependent on which BRANCH you are on, correct? Even further, __you__ as a developer? I guess I'm asking, Is Git HEAD going to be a repository-wide global thing, or individual for each dev?
bobobobo
@bobobobo: That's right, HEAD is like a pointer that points to the current branch. When you checkout a different branch, HEAD changes to point to the new one. The current HEAD is local to each repository, and is therefore individual for each developer.
Greg Hewgill
A: 

I believe HEAD is "the most current".

jamesj629