Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git remove same file with different capitalization

Tags:

git

Because of some necessities, I've changed .git/config ignorecase = false in order to make case sensitive. Then rename file from upper case to lower case. For example, I renamed Account_Model.php to Account_model.php 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 Account_model.php (What I want) and the other is Account_Model.php.

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.

like image 910
Benyi Avatar asked Oct 19 '25 09:10

Benyi


1 Answers

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.

like image 198
Schwern Avatar answered Oct 22 '25 00:10

Schwern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!