A while back I was working on a project where the website was under version control using git. Whenever I would try to run
git status before checking out new changes, I would always get an error:
$ git status error: bad index file sha1 signature fatal: index file corrupt fatal: 'git status --porcelain' failed
A quick internet search brought up what I thought was the solution:
$ rm -f .git/index $ git reset
I say I thought this was the solution. But it wasn’t. I’d try to run
git status after this, and the index file would still be corrupt. I struggled with this for a long time, until I finally realized what the problem was. It turned out that there were two folders in the git repo that contained
.git directories—in other words, what we had was nested git repositories. This wasn’t intentional, and I had no idea that these
.git directories were there. Once they were deleted, everything worked again.
Check to make sure that none of the non-submodule directories under your project have
.git directories in them.