fatal: could not parse HEAD Error When Committing
Solution 1
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
.
Solution 2
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
Comments
-
MichaelScaria almost 2 years
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?
-
MichaelScaria over 11 yearsI think you are right I ran
git fsck
and got this:notice: HEAD points to an unborn branch (trunk)
-
Lily Ballard over 11 years@MichaelScaria: Well that's actually my fault. I said
trunk
instead ofmaster
, because I've been using git-svn too much lately. Try again withgit symbolic-ref HEAD refs/heads/master
. I'll update my post appropriately -
MichaelScaria over 5 yearsIt seems like you didn’t initialize git properly in your folder. Did you remember running
git init
? -
Nodira over 5 yearsYes you are right. I forgot to
git init
. But, when I remembered I had have already been working for long hours and couldn't loose those changes. -
Camunatas over 2 yearsthis is the easiest and most robust solution