How to make git ignore changes in case?
WindowsGitWindows Problem Overview
I'm not too sure what is going on here, but sometimes a particular file in my repository will change the case of its 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.
Windows Solutions
Solution 1 - Windows
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
Solution 2 - Windows
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.
Solution 3 - Windows
In git version 1.6.1.9 for windows I found that "ignorecase=true' in config was already set by default.
Solution 4 - Windows
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.
Solution 5 - Windows
To force git to recognize the change of casing to a file, you can run this command.
- Change the File casing however you like
git mv -f mynewapp.sln MyNewApp.sln
The previous command seems to be deprecated now.
Solution 6 - Windows
- From the console: git config core.ignorecase true
- Change file name capitalisation
- Commit
- From the console: git config core.ignorecase false
Step 4 fixed problems checking out branches with a different capitalisation.
Solution 7 - Windows
git mv FileName fileNameTemp
then
git mv fileNameTemp fileName
will solve your problem without the need to commit.