Buenas.
Esto podría ocurrir cuando algunos archivos de la carpeta .git
, específicamente el index
se daña.
para arreglarlo intenta (en linux):
rm -f .git/index
git reset --keep
Explicación
Para reproducir el error:
arie@dev:/var/www/repo$ ls -lha .git/ # Ver los archivos de .git/
[... otros archivos ...]
-rw-r--r-- 1 arie arie 175K mar 2 13:18 index # Fichero correcto
arie@dev:/var/www/repo$ git add . # Este funciona!
arie@dev:/var/www/repo$ truncate -s 1000 .git/index # Echamos a perder :(
arie@dev:/var/www/repo$ git add . # Error!
error: bad index file sha1 signature
fatal: index file corrupt
El fichero Index
The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also common to refer to it as the staging area. The Three States - Git Basics
El "index", "stagging area" o "área de preparación" es un fichero que contiene la captura del árbol de trabajo actual que será incluida en el siguiente "commit".

El comando git reset [<mode>] [<commit>]
This form resets the current branch head to <commit> and possibly updates the index (resetting it to the tree of <commit>) and the working tree depending on <mode>. Git reset - Documentación git
Git reset reubica el puntero "head" al commit seleccionado entre < >
, junto con esto actualiza el fichero "index". Si no se provee el paramatro <commit>
, por defecto es HEAD
. Para <mode>
es --mixed
.
opción --keep
Resets index entries and updates files in the working tree that are different between <commit> and HEAD. If a file that is different between <commit> and HEAD has local changes, reset is aborted. Opción --keep - Documentación Git
Puedes leer este articulo en el blog de git-scm(en Ingles) para tener mucha mas información.