How to make git ignore changes in case?

Viewed 117825

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.

7 Answers

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

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

To force git to recognize the change of casing to a file, you can run this command.

  1. Change the File casing however you like
  2. git mv -f mynewapp.sln MyNewApp.sln

The previous command seems to be deprecated now.

  1. From the console: git config core.ignorecase true
  2. Change file name capitalisation
  3. Commit
  4. From the console: git config core.ignorecase false

Step 4 fixed problems checking out branches with a different capitalisation.

git mv FileName fileNameTemp

then

git mv fileNameTemp fileName

will solve your problem without the need to commit.

Related