How are the terms “HEAD”, “head”, and “tip” different?

泄露秘密 提交于 2019-12-02 02:18:39

问题


Initial Understanding

HEAD

  • "indicates the head of the current branch."
  • so, there is only one HEAD.

head

  • refers to the most recent commit of any branch.
  • "...the most recent commit (or "head") of a branch..."
  • so, there are as many heads as there are branches.

tip

  • refers to the most recent commit of any branch.
  • so, tip is synonymous with head

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)


回答1:


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.



来源:https://stackoverflow.com/questions/26049827/how-are-the-terms-head-head-and-tip-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!