I change the capitalization of a directory and Git doesn't seem to pick up on it

GitMacos

Git Problem Overview


I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. It still thinks the directories are lowercase when I run git ls-files and other commands.

Is this harmless, or should I do something else to get Git to pick up on this change?

Git Solutions


Solution 1 - Git

You can tell git to take account of the case by running

git config core.ignorecase false

Solution 2 - Git

You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so:

$ git mv somename tmpname
$ git mv tmpname SomeName

Solution 3 - Git

How to git mv on Mac Case-Sensitively

This is happening because Mac OS X implements case preserving and case insensitivity features that are intended to help you.

Although the double rename suggestions in the other answer will work, I recommend the use of '--force' for a best practice result:

$ git mv --force somename SomeName


Note: if you try without the force option, git will barf on you like this:

$ git mv somename SomeName
$ fatal: destination exists, source=somename, destination=SomeName

In the above example, the git command fails and no files are changed in the filesystem or in git's index.

Solution 4 - Git

Try to change git config option core.ignorecase to false in your .gitconfig file.

Solution 5 - Git

The following steps helped me resolve the issue:

  1. Rename the folder to temp:

     mv Folder temp                  // It will rename your Folder to temp
    
  2. Stage and commit:

     git add .
     git commit -m "Temp"
    
  3. Rename temp folder to your choice:

     mv temp folder        // It will rename temp folder to the name of your choice(folder)
     git add .
     git commit -m "Folder Fixed"
    

Done - You can now push.

Solution 6 - Git

The reason for this is that LINUX-based OS or macOS ignore case sensitive for file/folder name. We need to resolve this problem by the below steps

For Exp, you want to change folder name from Base to base
1. mv Base base2
2. git add . && git commit -m "Fix folder name problem (wip)"
3. mv base2 base
4. git add . && git commit -m "Fixed folder name problem"

Solution 7 - Git

If you do git mv AAA aaa or git mv -f AAA aaa, it will not be work and you will have error fatal: renaming 'AAA' failed: Invalid argument.

Because AAA and aaa are ONE SAME folder/file on case-insensitive file systems, move AAA to aaa means move AAA as aaa/AAA.

So you should do

git mv AAA aaa.1
git mv aaa.1 aaa

I hope it will be helpful for you.

Solution 8 - Git

None of these actually helped me, I still was having git tell me to stash my changes, because my situation was that my local folder was capitalised but the remote not, and my branch was behind and I could no longer pull because of file capitalization differences in the folder structure.

The only way I could fix this was deleting my local branch and checking out the remote.

Solution 9 - Git

You can also do this manually without using GIT commands. Inside the .git folder, simply delete the folder with the name you want i.e SomeName . And then rename the folder somename to SomeName. More details at : How to fix folder name set to uppercase and git convert to lowercase

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondanView Question on Stackoverflow
Solution 1 - GitTaranView Answer on Stackoverflow
Solution 2 - GitPaul RView Answer on Stackoverflow
Solution 3 - GitDavid ManpearlView Answer on Stackoverflow
Solution 4 - GitPoomalairajView Answer on Stackoverflow
Solution 5 - GitRenil BabuView Answer on Stackoverflow
Solution 6 - GitgiapnhView Answer on Stackoverflow
Solution 7 - GitGapur KassymView Answer on Stackoverflow
Solution 8 - GitDerropsView Answer on Stackoverflow
Solution 9 - GitTahaView Answer on Stackoverflow