What is HEAD in Git?

后端 未结 22 2438
野的像风
野的像风 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:52

    HEAD refers to the current commit that your working copy points to, i.e. the commit you currently have checked-out. From the official Linux Kernel documentation on specifying Git revisions:

    HEAD names the commit on which you based the changes in the working tree.

    Note, however, that in the upcoming version 1.8.4 of Git, @ can also be used as a shorthand for HEAD, as noted by Git contributor Junio C Hamano in his Git Blame blog:

    Instead of typing "HEAD", you can say "@" instead, e.g. "git log @".

    Stack Overflow user VonC also found some interesting information on why @ was chosen as a shorthand in his answer to another question.

    Also of interest, in some environments it's not necessary to capitalize HEAD, specifically in operating systems that use case-insensitive file systems, specifically Windows and OS X.

提交回复
热议问题