Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

fatal: Failed to resolve HEAD as a valid ref

idurvesh June 2, 2016

Repost of: http://stackoverflow.com/questions/37594459/fatal-failed-to-resolve-head-as-a-valid-ref

I am getting fatal: Failed to resolve HEAD as a valid ref. whenever I try to commit.

I have tried

echo ref: refs/heads/master >.git/HEAD

but its not working

Also tried

git commit

its not working either from below sources

Git 'fatal: No such ref: HEAD' 

git tag: fatal: Failed to resolve 'HEAD' as a valid ref

Please help in..All my commit history is also gone

1 answer

0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2016

Sounds like your repository got corrupted. If you have it pushed to a remote, you can re-clone, then copy any changes you've made from the old working copy to the new.

idurvesh June 2, 2016

do you mean re clone and then copy paste made changes to working directory manually?

thinsoldier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2016

You can re-clone then copy > paste your entire directory with the changes into the new clone directory and do git status to confirm all your changes were copied.

What do you see in the output from git reflog?

I had a git in a dropbox folder once that got corrupted because of dropbox. Got into the habit of having both a real remote remote and a 2nd remote pointing to another clone on the same machine and pushing to both so just in case one gets corrupted I can just clone the other local one and if my house burns down I still have the remote in the cloud also.

idurvesh June 2, 2016

oh that's the good idea to replace complete root folder with newly cloned....

git reflog showin "fatal: your current branch appears to be broken" 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events