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

Viewed 88143

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?

9 Answers

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.

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"

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.

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.

Related