How do I rename a file in git that differs by case only? In my git (Xcode) project, I committed a filename with improper case.  Now I went to try to rename it, but when I commit, I get:


  fatal: Will not add file alias 'MyProject/MyFile.h' ('MyProject/MyFilE.h' already exists in index)


I'm sure this is because git isn't used to be running on a case-preserving, case-insensitive filesystem like HFS+.  But how do I get around it?

I tried renaming both files to something else, and committed that, and then renaming them back to what I want, but it still fails (with the same error message).
As asked and answered on stackoverflow, there's an easier way to do this that doesn't involve making a new file system in a disk image file:

Move your existing file aside, commit that move, then move it back using the case you'd like it to maintain and commit. Done.

Example:

mv foo foo2
git add -A
git commit -m "renaming"
mv foo2 FOO
git add -A
git commit --amend -m "renamed foo to FOO"