Case-sensitivity problem with Git in OS X

I’ve several times experienced problems with files and folders having incorrect case in Git repositories in OS X, so I decided to gather some possible fixes and solutions to this problem. If you have any suggestions or comments, please consider sharing it with me in a comment.

Hacks

First off, here’s a solution published at Coderwall.com:

git mv filename filename_tmp
git mv filename_tmp Filename
git commit -m "Set correct case for filename"

The author mentions that this is a hack and that it could possibly mess up other users’ repositories, and that a git pull by other users won’t include this change.

In a comment to that article, a user suggests the following approach instead:

git mv --force filename Filename
git commit -m "Set correct case for filename"

According to the comment, a git pull would now rename the file for other OS X users as well.

Receive a weekly update in your inbox

I'd very much appreciate it if you'd be interested in getting an email delivered directly to your inbox every Sunday morning at 9AM with a summary of my tech related blog posts from the last week. I will not in any way use your email address for anything else. That's a promise.

Leave a Comment