Git 在所有平台上是否都不区分大小写?
在Windows上使用msysgit,我可以执行以下操作:Git 在所有平台上是否都不区分大小写?,git,Git,在Windows上使用msysgit,我可以执行以下操作: git checkout head 或 两种方法都有效。我没有linux环境可供测试,但我只是好奇:HEAD设计是否不区分大小写?在所有平台上都是这样吗?HEAD在Linux上区分大小写 例如: $ git checkout head error: pathspec 'head' did not match any file(s) known to git. $ git checkout HEAD Your branch is up-
git checkout head
或
两种方法都有效。我没有linux环境可供测试,但我只是好奇:
HEAD
设计是否不区分大小写?在所有平台上都是这样吗?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。在Linux环境中,HEAD区分大小写。据我所知,它只在mysysgit中不区分大小写
在Linux环境中,它给出:
错误:pathspec'head'与git已知的任何文件都不匹配。
回答有关Mac OSX的问题(Mavericks):
但是:
顺便说一下,该散列是当前分支的头(在我的测试中,它包含在.git/refs/heads/master
中)
有趣的行为
(git 1.8.5.2)HEAD的大小写敏感度取决于操作系统文件系统的大小写敏感度 当您签出HEAD时,git实际上会在文件夹.git下查找名为“HEAD”的文件。如果您用小写字母键入HEAD,git将用小写字母查找文件名。您可以看到.git/HEAD文件实际上包含指向的提交头的哈希代码 因此,HEAD的典型病例敏感性为:
- Linux上区分大小写
- Windows、MacOS上不区分大小写
@
。MacOS默认不使用不区分大小写的文件系统吗?谢谢Keith,我没有注意到这一点@Lorenzo Marcon,你在Mac操作系统中使用区分大小写的HFS+版本吗?我可以用git--version
returninggit version 2.20.1(Apple git-117)
在Mojave上重现Lorenzo Marcon的行为,我的文件系统不区分大小写。例如,我可以使用rma
删除文件a
。另外,git push origin HEad
显示为pushHEad
,git symbolic ref HEad
和git symbolic ref HEad
都返回refs/heads/foo_branch
,git branch HEad
和git checkout HEad
,都很有趣,而且git branch-d HEad
做了一些令人惊讶的正确事情,删除了HEad
分支,而没有明显破坏我的回购协议。
$ 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'.
$ 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