Can git log --decorate unambiguously tell me whether the HEAD is detached?

前端 未结 2 476
栀梦
栀梦 2020-12-11 04:23

I know that, in Git parlance, \"detached HEAD\" corresponds to a state in which the symbolic reference HEAD is not pointing to any branch. I also know that

2条回答
  •  萌比男神i
    2020-12-11 05:06

    [Edit: since Git 2.4, well, see VonC's answer. The text below is for versions of Git before 2.4.]

    Unfortunately, no. I keep wishing git log's --decorate used my HEAD= syntax. If it did, you would get:

    4d860e9 (HEAD, master) Remove trailing whitespace
    9a2ef02 Correct typo in header
    f0badb5 Add to-do section to README
    

    when you are carrying your head under your arm:


    (source: shutterstock.com)

    but you would get this instead:

    4d860e9 (HEAD=master) Remove trailing whitespace
    9a2ef02 Correct typo in header
    f0badb5 Add to-do section to README
    

    when you are not in hallowe'en mode.

提交回复
热议问题