Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: could not parse HEAD Error When Committing

Whenever I try to commit my work, I get this error.

fatal: could not parse HEAD

What should I do if I want to preserve my changes?

like image 674
MichaelScaria Avatar asked Jan 22 '13 00:01

MichaelScaria


2 Answers

Do you know what branch HEAD was supposed to point to? Was it master? Run git symbolic-ref HEAD refs/heads/master.

Basically, the symbolic reference with the name HEAD is corrupted somehow. You (or software you ran) must have gone poking around the .git dir. If I were you I would check to make sure nothing else in your repo is damaged. You can verify your object database by running git fsck.

like image 63
Lily Ballard Avatar answered Nov 04 '22 18:11

Lily Ballard


Copy the new files you recently changed to another directory, delete the git local repository in your computer, clone the repository again using 'git clone URL', move the recently changed files your copied to another back to this directory, do git add files, git commit -m " ur msg ", and push to the remote repository using git push

like image 4
uche Godfrey Avatar answered Nov 04 '22 18:11

uche Godfrey