search

Home  >  Q&A  >  body text

Git 中 HEAD 是什么东西,为什么会出现在分支里?

如题,但是这个分支实际上又是不存在的。

高洛峰高洛峰2795 days ago961

reply all(6)I'll reply

  • 仅有的幸福

    仅有的幸福2017-04-28 09:06:18

    To put it simply, HEAD is the cursor of the currently active branch. The vivid memory is: wherever you are now, HEAD points to where you are, so Git knows that you are there!

    However, HEAD does not only point to the top of the branch (the one with the latest time node). In fact, it can point to any node. It is what Git uses internally to track the current position.

    My answer is not rigorous, just to give you a brief idea. Please read the official manual for more details.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-04-28 09:06:18

    current pointer

    reply
    0
  • 怪我咯

    怪我咯2017-04-28 09:06:18

    Reprinted from the answer on http://stackoverflow.com/questions/2304087/what-is-head-in-git If the translation is wrong, please complain gently

    You can think of HEAD (uppercase) as "current branch". When you switch branches with git checkout, the HEAD revision redirects to the new branch. Sometimes HEAD will point to a revision without a branch name. This situation is called "detached HEAD"

    head (lowercase) is a reference to the commit object. Each head has a name (branch name or tag name, etc.), but by default, each repository called master will have a head, and a repository can contain any number. head. At any time, as long as this head is selected to become the "current head", then this head becomes HEAD, always capitalized

    reply
    0
  • PHP中文网

    PHP中文网2017-04-28 09:06:18

    Conceptually, this is what @nightire said. As for HEAD appearing in the branch column, it can be understood as creating a shortcut on the desktop that points to the QQ icon. It seems to be two different things from the QQ icon, but in fact it points to both. It is qq.exe in the installation directory.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-28 09:06:18

    Learn GIT Recommended GIT Tutorial by Teacher Liao Xuefeng

    Excerpt from one of them:

    Strictly speaking, HEAD does not point to the commit, but to the master. The master points to the commit, so HEAD points to the current branch.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-28 09:06:18

    As mentioned above, let me add that HEAD is the location of your current working directory. You can use the checkout command to change the location pointed by HEAD. Note that HEAD does not necessarily point to a branch, it can also point to a commit

    reply
    0
  • Cancelreply