'How to repair corrupt git repository - fatal: Not a git repository?

I looked at many other questions to no avail.

My laptop froze during git reset --hard or git checkout branch. Not sure. After the hard reset I see

$ git fsck
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I saw that .git/index was an empty file. Deleting it yields no results.

Any ideas how to restore? I have most my stuff pushed to a remote but I prefer to keep my branches and stashes. I have some useful stuff in there and even if I can track most of it remotely, would be hard.

git


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source