Benyi Benyi - 2 months ago 25
Git Question

Git remove same file with different capitalization

Because of some necessities, I've changed

ignorecase = false
in order to make case sensitive. Then rename file from upper case to lower case. For example, I renamed
manually, even other branches.

By the different case, git makes the
Uncommitted changes
, then I committed the new files with lower case (git assume the lower case new files).

Now I'm in trouble. I pull the repo for the server where to have deployments, the directory creates 2 files. One is
(What I want) and the other is

They became separate two files! But turn back to my local, I only see 1 file in the directory. (Because of the one, I cannot delete the upper case one)

If I change some of them, the two file with different cases will alert at the same time. The diff shows the same modifies.

Two file with same diff

But I only can see only one in the directory.

Only 1 file in the directory

I cannot delete the upper case one. (If could, I think the lower case one would be delete too.

There's a way can change case by the command. I know, I chose the wrong way.

So how can I deal with that two case files, and keep the changes (only one file with lower case) forever?

Thank you so much.


OS X's filesystem is, by default, case-insensitive. So if you have two files in a Git repository with the same name but different cases you get the problem you're having now.

A simple work around is to use Disk Utility to create a case-sensitive disk image, clone the repo onto that, fix the problem there, and push the fix.

To make the disk image...

  • Open Disk Utility.
  • Do File -> New Image -> Blank Image.
  • Set the Format to be OS X Extended (Case-sensitive, Journaled).

enter image description here

It will automatically be mounted and waiting for you in /Volumes. After you clone you should see both files and can do with them as you please.