I was cleaning up a few things on my drive and moved several folders around. Unbeknownst to me at the time, one flash drive was still vfat when I thought it was ext2/3. For some reason no obvious warning such as "cannot change permissons on file xyz" appeared when moving files. So I assumed everything worked fine and I committed a small change to a file in my main git repository, which was moved, too.
That wasn't so smart.
As I ran git status too see how things were looking I got a listing of every file in the repo having been modified. Next I noticed that nearly all files had the executable bit set, all in .git as well. Then I noticed it was a vfat partition and moved the directory back to a Linux partition.
Then, back on the old drive, the only error message that came back was:
fatal: Not a git repository
The first thing I tried to remedy this was removing the executable bit from all files and a helpful forum post supplied the useful one-liner:
find . -type f -print0 | xargs -0 chmod a-x
Still, the fatal error message persisted. It had to be somehow connected to the .git directory which looked fine but when compared to a newly created test repository it became obvious that the one commit on the vfat partition had changed the filename HEAD to head…must be a default policy for case-insensitive filesystems…
Anyway, all worked well after renaming head back to HEAD and a simple git checkout -f got rid of any remaining problems with incongruent files. Maybe this post will be a helpful shortcut to somebody else who wasn't paying attention.
I was trying to share a git repository between my Linux and Windows machines with a FAT32 and that failed with exactly the same error as you got. Thanks for shedding some light on this. I'll have to find another way to share the data.
I wanted to share single git repository between Linux and Windows on NTFS partition. Both OSes recognize the repository (I'm using msys-git on Win), but running 'git status' on Windows shows heaps of modified files - while in Linux that same repository has "no changes to commit" :(
I haven't really found a way to share a repository between the 2 OSes, so I guess I'll just use different repositories.
1) NTFS is case-sensitive. The FS driver is configured to be case insensitive by default, but that can be easily changed in registry (HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive).
2) The sharing problem is due to GIT's end-of-line behavior (and there is also old and new behavior). By default GIT changes all EOL characters to "native" for the platform where the checkout occurred. This will lead to problem if you share the repo between two OSes or even two differently-configured GIT clients. You can configure all your tools to use LF and re-clone the repo to make sharing possible.