How to recover `.git/index` locally?

dyarbrough picture dyarbrough · Jul 8, 2016 · Viewed 8k times · Source

I accidentally deleted .git/index, is there a way to recover it? It's permanently deleted. I haven't committed anything yet.

Answer

kenorb picture kenorb · Jul 9, 2016

To rebuild the index file, you can try these two commands:

git reset         # re-scan the working directory
git add -u        # update the index