如果提交的签出不是您的分支之一的名称,则将获得一个分离的HEAD。代表分支尖端的SHA1仍然给出分离的HEAD。仅签出本地分支名称可以避免该模式。
请参见使用分离的HEAD提交
分离HEAD时,除了没有命名分支得到更新之外,提交工作与正常工作相同。(您可以将其视为匿名分支。)

例如,如果您在未先跟踪的情况下签出“远程分支”,则可能会得到一个分离的HEAD。
参见git:切换分支而不拆卸头部
使用Git 2.23(2019年8月),您不再需要使用令人困惑的git checkout命令。
git switch 也可以签出一个分支,并获得一个分离的HEAD,除了:
要在HEAD~3不创建新分支的情况下签出提交以进行临时检查或实验,请执行以下操作:
git switch --detach HEAD~3
HEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits'
看到:
C:\Users\vonc\arepo>git checkout origin/master
Note: switching to 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
VS. 使用新git switch命令:
C:\Users\vonc\arepo>git switch origin/master
fatal: a branch is expected, got remote branch 'origin/master'
如果要创建一个跟踪远程分支的新本地分支:
git switch <branch>
如果<branch>未找到,但确实在一个<remote>具有匹配名称的远程站点(称为)中存在跟踪分支,则将其视为等效于
git switch -c <branch> --track <remote>/<branch>
没有更多的错误!
不再有多余的超脱头!
branch-name@{n},即的第n个位置branch-name。但是无论如何,在某个时候一定有一个git checkout <rev>。如果这没有敲响,那可能是您做了Will所提到的-尝试这样做,git checkout <file>并偶然指定了一个修订版本。