Case sensitivity in Git

GitCase Sensitive

Git Problem Overview


I've run into a problem with git. Basically I set to false core.ignorecase because I wanted to change the case of the names of some folders (since I'm under OSX with a case-insensitive filesystem, the changes weren't shown otherwise). When I pulled my data, I've noticed that now every renamed folder appears twice on the repository, with both the old and the new name. I don't know what to do to remove the old folders since they don't appear locally (I've try to set core.ignorecase to true again but it isn't helping).

Git Solutions


Solution 1 - Git

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"

Solution 2 - Git

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

Solution 3 - Git

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

Solution 4 - Git

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".

Solution 5 - Git

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

Solution 6 - Git

There is a longish recent thread on case sensitivity issues on the [email protected] 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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionentropidView Question on Stackoverflow
Solution 1 - GitVonCView Answer on Stackoverflow
Solution 2 - GitBrandon YangView Answer on Stackoverflow
Solution 3 - GitadibView Answer on Stackoverflow
Solution 4 - GitArafangionView Answer on Stackoverflow
Solution 5 - GitMohamed EL HABIBView Answer on Stackoverflow
Solution 6 - GitPhilip OakleyView Answer on Stackoverflow