You seem to have lost your HEAD , so you have to recreate it. You can do it using this.
echo ref: refs/heads/master >.git/HEAD
This will create a HEAD file in your .git folder. This should solve your problem.
Also try running the git fsck command. It checks the connectivity and reliability of objects in the database.
git fsck --lost-found
Use this to scan unreachable objects. It will write dangling objects in .git/lost-found/commit/ or .git/lost-found/other/ , depending on the type. If the object is a blob, the contents are written to the file, not its object name.
source share