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
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.