If the problem is with the index as the staging area for commits (i.e. .git/index
), you can simply remove the index (make a backup copy if you want), and then restore index to version in the last commit:
On OSX/Linux/Windows(With Git bash):
rm -f .git/index
git reset
On Windows (with CMD and not git bash):
del .gitindex
git reset
(The reset
command above is the same as git reset --mixed HEAD
)
You can alternatively use lower level plumbing git read-tree
instead of git reset
.
If the problem is with index for packfile, you can recover it using git index-pack
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…