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
好的。
.git
当文件夹中的某些文件,特别是文件夹index
损坏时,可能会发生这种情况。修复它尝试(在 linux 上):
解释
要重现错误:
索引文件
“索引”、“暂存区”或“暂存区”是一个文件,其中包含将包含在下一次“提交”中的当前工作树的捕获。
git reset [<mode>] [<commit>] 命令
Git reset 将“head”指针重新定位到 中选定的提交
< >
,同时更新“index”文件。如果未提供参数<commit>
,则默认为HEAD
. 因为<mode>
是--mixed
。--保留选项
您可以在 git-scm 博客上阅读这篇文章以获取更多信息。