Risinek
Risinek

Reputation: 426

How to recover git repository after deleting .git/HEAD file

I've got some issues with git and git itself suggested me to delete .git/HEAD if problem persists. So I did it and now git says fatal: Not a git repository.

I tried running git init on which git responded with reinitializing existing repository but nothing really changed. I'm unable to run any git command.

Upvotes: 1

Views: 74

Answers (1)

Risinek
Risinek

Reputation: 426

Create new file in .git folder named HEAD and paste there full SHA of some commit. Then you can run git status to check it current state. Now you can simply run git reset and you will end up in latest state before git repository corruption.

Upvotes: 1

Related Questions