I’m just starting to use git for source control. Tonight I got an error when I tried to commit:
$ git add ./foo/bar/
error: unable to create temporary sha1 filename .git/objects/95: File exists
error: foo/bar/baz: failed to insert into database
Luckily, someone else ran into this before me. The magic incantation:
git fsck
git prune
git repack
git fsck
and then I was able to add my files.
I ran into another case where this didn’t help. In that instance,
git gc
was able to get me committing again.