I'm learning git so please forgive me if this has been answered before. I added a file README.txt
to the working directory. git status
tells me that this is the only untracked file. I then ran git add readme.txt
. Running git status
now tells me once again that README.txt
is the only untracked file. However, if I then run git add README.txt
it now shows up as a new file. Does this mean that git is adding a snapshot of the file readme.txt
which doesn't exist? I don't understand as I thought that git was case insensitive.
I thought that git was case insensitive.
Not really. There's a config setting core.ignorecase
which is normally set to true in Windows; the docs say
If true, this option enables various workarounds to enable Git to work better on filesystems that are not case sensitive
But that's a long way from saying Git is case-insensitive. I reproduced what you did and I think you found a bug.
$ git checkout -b test
Switched to a new branch 'test'
$ echo hello > README.txt
$ git status
On branch test
Untracked files: (use "git add <file>..." to include in what will be committed)
README.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git add readme.txt
$ git status
On branch test
Untracked files: (use "git add <file>..." to include in what will be committed)
README.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git diff --cached
$
One of two things should have happened: either Git should have complained that readme.txt
didn't exist when I (and you) added it, or it should have added the contents of README.txt
to the cache. It didn't do either of those things: no error from git add
and no results listed by git diff --cached
.
So my advice is treat Git commands as case-sensitive even when core.ignorecase
is set to true.