What is HEAD in Git?

后端 未结 22 2265
野的像风
野的像风 2020-11-22 10:02

You see the Git documentation saying things like

The branch must be fully merged in HEAD.

But what is Git HEAD exac

22条回答
  •  失恋的感觉
    2020-11-22 10:53

    You can think of the HEAD as the "current branch". When you switch branches with git checkout, the HEAD revision changes to point to the tip of the new branch.

    You can see what HEAD points to by doing:

    cat .git/HEAD
    

    In my case, the output is:

    $ cat .git/HEAD
    ref: refs/heads/master
    

    It is possible for HEAD to refer to a specific revision that is not associated with a branch name. This situation is called a detached HEAD.

提交回复
热议问题