大小写敏感性

我遇到了 Git 的问题。基本上,我设置为 false core.ignorecase是因为我想更改一些文件夹的名称大小写(因为我在 OSX 中使用了不区分大小写的文件系统,所以这些更改没有以其他方式显示)。当我提取我的数据时,我注意到现在每个重命名的文件夹在存储库中出现两次,同时出现新名称和旧名称。我不知道如何删除旧的文件夹,因为它们不会在本地出现(我试图将 core.ignorecase再次设置为 true,但没有帮助)。

70677 次浏览

May be a workaround similar to this comment in an msysgit issue (for another case-insensitive OS: Windows) could help?

I've encountered this same issue. Refactored a package name in Eclipse and switching to a previous build broke due to the folder name not reverting. I'm using Windows 7, Git 1.7.0.2.msysgit.0

My folder was renamed in Windows to "folder" but was displayed as "Folder" in Git.
I fixed the issue by renaming it to "Folder" in Windows and then running:

git mv "Folder" "Folder2"
git mv "Folder2" "folder"

Note that since git 2.0.1 (June 2014), git mv Folder folder should just work!

See "Git: Changing capitalization of filenames"

Mac OS X by default is "case insensitive but case preserving". This is an important distinction.

I suggest you create another disk image, and specifically format it as "HFS Case Sensitive".

There is a longish recent thread on case sensitivity issues on the git@vger.kernel.org discussion forum titled Bug? Git checkout fails with a wrong error message which highlights the issues, and things to try, of case sensitivity between different platforms.

You can create a disk image (preferably a sparsebundle disk image) with a case-sensitive file system and checkout your git repository there.

The Disk Utility screenshot below shows how to create a case-sensitive disk image.

Disk Utility Settings

git mv "Folder" "Folder2"
git mv "Folder2" "folder"
git commit -a -m "my message"

Use the following command on macOS. This will change your git configuration to be case sensitive on filenames.

git config core.ignorecase false

You can set this globally by editing ~/.gitconfig and setting it under core such as:

[core]
ignoreCase = false