如何从 git 中的 "unordered stage entries in index" 错误中恢复

How to recover from "unordered stage entries in index" error in git

我刚刚将我的 git2.0.5 升级到 2.3.6,现在我无法 运行 git svn fetch 我的其中一个存储库:

$ git svn fetch
fatal: unordered stage entries in index
write-tree: command returned error: 128

git status 显示一些未跟踪的文件,但其他方面都很干净。

我找到了引入此检查的更改,摘要“read_index_from(): catch out of order entries when reading an index file" (first appearing in 2.2.0), and some mailing list discussion 其中包括:

I think we have been discussing how to protect broken index file left by tools other people wrote, so I wouldn't be so surprised if our current toolset does not let you recreate certain breakages ;-)

我不记得 运行在这个 repo 上有任何其他工具;除了一长串 git svn fetches 之外,它没有做太多日常工作。 (但它已经存在了几年,所以谁知道呢。)

无论如何,我该怎么做才能从这种情况中恢复过来?我试图找到一个具有多个索引条目的路径,但没有得到任何结果:

$ git ls-files -s | cut -f 2-100 | sort | uniq -c | grep -v '^[ \t]*1 '

what can I do to recover from this situation?

像这样

rm .git/index
git add -A