Can't add files to staging area in git due to case sensitivity

1.7k views Asked by At

I have a list of file changed under my working copy, but the files keep in the unstaged area. I use SourceTree and every time I drag and drop the files to the staging area they simply do not move!

I've tried using:

git add -A

But I had no luck, after that if I do git status the files remain in the unstaged area.

What's interesting is that I performed a clean clone to another folder on my system, and the files automatically show up changed!

Running git status shows:

git status --short
 M resources/file1
 M Resources/file1
 M resources/file2
 M Resources/file2
1

There are 1 answers

1
Edgar On BEST ANSWER

It looks like either you changed the path to some files that were already tracked by git and git is not enjoying it that much or perhaps you or someone with access to your repo messed around with the ignorecase flag for the git configuration.

Try to run this at the root of your repository and see what comes out:

cat .git/config | grep "ignorecase"

This is false by default but can be changed to true for systems that are not case sensitive.

From the documentation I think no one but you would be able to change your flag for an already-cloned-working-copy, but when performing a new clone the flag may be set to true.

Try to see if your clean clone outputs the same value for the ignorecase flag, and if it has the correct folder name (Capitalised) and if so, try to apply your changes from the older working copy to this one so start you can start working from there, I have experienced erratic behaviour within git when moving files/folders around or when renaming them even more so.

On a perhaps more extreme solution, make a silly commit renaming the folder to something else where you introduce a bigger change to the folder's name and not just a capitalised letter, and then make another commit putting the original name but capitalised this time.

Inform other users of your repository that they may have to perform clean clones as well to avoid problems.