Question

I'm not too sure what is going on here, but sometimes a particular file in my repository will change the case of it's name. e.g.,:

before: File.h

after: file.h

I don't really care why this is happening, but this causes git to think it is a new file, and then I have to go and change the file name back. Can you just make git ignore case changes?

[edit] I suspect it is Visual Studio doing something weird with that particular file, because it seems to happen most often when I open and save it after changes. I don't have any way to fix bugs in VS however, but git should be a bit more capable I hope.

Was it helpful?

Solution

Since version 1.5.6 there is an ignorecase option available in the [core] section of .git/config

e.g. add ignorecase = true

To change it for just one repo, from that folder run:

git config core.ignorecase true

To change it globally:

git config --global core.ignorecase true

OTHER TIPS

In git version 1.6.1.9 for windows I found that "ignorecase=true' in config was already set by default.

You can force git to rename the file in a case-only way with this command:

git mv --cached name.txt NAME.TXT

Note this doesn't change the case of the file in your checked out copy on a Windows partition, but git records the casing change and you can commit that change. Future checkouts will use the new casing.

The situation described in the question is now re-occuring with Mac OS X, git version >= 1.7.4 (I think). The cure is to set your ignorecase=false and rename the lowercased files (that git changed that way, not Visual Studio) back to their UsualCase by hand (i.e. 'mv myname MyName').

More info here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top