Shaun Luttin
Shaun Luttin

Reputation: 141434

How are the terms "HEAD", "head", and "tip" different?

Initial Understanding

HEAD

head

tip

Please correct me if I'm wrong. Also, please provide documentation on the usage of "tip".

New Understanding after Reading Answer

Each branch points at a commit. The head (or tip) is the commit at which a branch points. If there are ten branches then there are ten heads and ten tips!

HEAD is a "you are here" marker that points at a commit in one of two ways: most of the time, HEAD points to a branch which in turn points at a commit; other times, HEAD points directly at a commit. The latter is called detached HEAD.

Quotes are from git(1)

Upvotes: 3

Views: 619

Answers (1)

jub0bs
jub0bs

Reputation: 66183

Branches (a.k.a. branch heads) mark points of interests in your repo. The metaphor isn't perfect, but you can think of branches as some sort of "bookmarks". Each branch points to a commit; that commit is called the tip of the branch.

HEAD (note the uppercase) is different. It usually points to a branch, indicating which point of interest in your repo you're currently at. However, in some cases, HEAD may also point directly to a commit (in which case your repo is said to have a "detached HEAD").

You can think of HEAD as

  1. a "you-are-here" marker on the metro map that is your commit graph; or
  2. an indicator of which branch (if any) is currently checked out.

For instance, in the following repository, the tip of the master branch is the commit of abbreviated ID f42c5; the tip of the develop branch is the commit of abbreviated ID 190a3; HEAD points to master, indicating that master is currently checked out.

enter image description here

Upvotes: 4

Related Questions