3

What is the difference between the Git HEAD and tip?

Sorry if this has been asked somewhere else.. haven't seen any other questions on this.

Marcus Leon
  • 53,069
  • 115
  • 287
  • 420
  • The Git `HEAD` points to the tip of the current branch _except_ in the detached HEAD state, in which case it points to the commit which you just checked out. – Tim Biegeleisen Sep 28 '16 at 16:10
  • Possible duplicate of [What is HEAD in Git?](http://stackoverflow.com/questions/2304087/what-is-head-in-git) – Don Branson Sep 28 '16 at 19:42

1 Answers1

6

From gitglossary (probably accessible via git help glossary on computers with git installed.):

branch
A "branch" is an active line of development. The most recent commit on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch head, which moves forward as additional development is done on the branch.

head
A named reference to the commit at the tip of a branch. Heads are stored in a file in $GIT_DIR/refs/heads/ directory, except when using packed refs. (See git-pack-refs[1].)

HEAD
The current branch. In more detail: Your working tree is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the heads in your repository, except when using a detached HEAD, in which case it directly references an arbitrary commit.

With two definitions of "head," differentiated by capitalization, there does seem to be room for confusion. But a quick summary appears to be:

A tip is the most recent commit on a branch. There is one tip per branch.

A head (all lowercase) is somewhat like a tag in that it's a conveniently named reference to the tip of a branch. Unlike a tag, a head will automatically change which commit it references when you add a commit to a branch. There is one head per branch.

The HEAD (all uppercase) is whatever commit you currently have checked out. There is only one HEAD.

Community
  • 1
  • 1
8bittree
  • 1,709
  • 1
  • 18
  • 24