在Windows上使用msysgit,我可以这样做:
git checkout head
或
git checkout HEAD
要么有效。我没有Linux环境可以测试,但我只是好奇:HEAD
是否因设计不敏感?在所有平台上都是这样吗?
答案 0 :(得分:10)
HEAD
在Linux上区分大小写。
例如:
$ git checkout head
error: pathspec 'head' did not match any file(s) known to git.
$ git checkout HEAD
Your branch is up-to-date with 'origin/master'.
Ubuntu 14.04上的Git版本1.9.1。
答案 1 :(得分:8)
HEAD的区分大小写取决于操作系统文件系统的区分大小写。
当您结帐HEAD时,git实际上会在文件夹.git下查找名为“HEAD”的文件。如果你用小写字母键入HEAD,git会查找带有小写字母的文件名。您可以看到.git / HEAD文件实际上包含指向的提交HEAD的哈希码。
因此,HEAD的案例敏感性是:
答案 2 :(得分:1)
HEAD在Linux环境中区分大小写。据我所知,它的情况仅在mysysgit中不敏感。
在Linux环境中,它提供:error: pathspec 'head' did not match any file(s) known to git.
答案 3 :(得分:1)
回答报道Mac OSX(小牛队):
$ git checkout HEAD
Your branch is up-to-date with 'origin/master'.
但:
$ git checkout head
Note: checking out 'head'.
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 performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at f44b740... fix if endScreen(s) not present
顺便说一句,那个哈希是当前分支的头部(在我的测试中,同样包含在.git/refs/heads/master
中)
有趣的行为。
(git 1.8.5.2)