HEAD

satya - 3/10/2019, 4:45:49 PM

What is HEAD in Git?

What is HEAD in Git?

Search for: What is HEAD in Git?

satya - 3/10/2019, 4:56:08 PM

Few key points on HEAD

HEAD refers to the current branch (that is checked out)

For example you can do "cat .git/HEAD" it will have "ref: refs/heads/master"

Each branch then refers to its latest commit point

An intermediate commit point of a branch can have a tag

A HEAD, if not otherwise specified, only refers to a branch that is current and indirectly points to the head of that current branch.

A HEAD can be made point to an intermediate commit point of the current branch or a tagged commit point of another branch. In such cases it is called a detached HEAD

satya - 3/10/2019, 4:56:38 PM

Here is a wonderful description of Detached HEAD

Here is a wonderful description of Detached HEAD

satya - 3/10/2019, 4:57:43 PM

I have talked more about this while talking about Branches

I have talked more about this while talking about Branches

satya - 3/10/2019, 4:58:16 PM

I have talked about this with "Checkout" as well

I have talked about this with "Checkout" as well

satya - 3/10/2019, 4:59:26 PM

So HEAD really tells git what the current branch is :)

And it is switched to a different branch with checkout

it is synonymous with checking out a branch