Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filename capitalization changes ignored in git Git on Windows [duplicate]

I have a reactjs application and I am normalizing all file names to be lowercase to comply with Nodejs best practices

However when I change file names within Visual Studio Code, these changes are ignored by git, so I am unable to commit my changes.

I followed the steps outlined here to turn off git's default file case ignoring for Windows, but nothing changes after I verify it is toggled to off -- my file name changes occur but git doesn't pick up changes to allow me to commit them. switching branches resets the filename capitalization changes I have made.

How can I commit my changes to file name capitalization in git?

like image 752
TheFastCat Avatar asked Dec 24 '22 13:12

TheFastCat


1 Answers

The problem arises with file systems that are case insensitive. So myfile.js and myFile.js are actually the same file as far as the file system is concerned.

So to get around it you need to use a different filename, commit it, and then rename again, like this

git mv myFile.js temp-myfile.js
git commit -am "Temp file rename"

followed by

git mv temp-myfile.js myfile.js
git commit -am "Renamed to final destination

That should do the trick

like image 148
Mikkel Avatar answered Dec 26 '22 09:12

Mikkel