fatal: Failed to resolve HEAD as a valid ref

I have also encountered the same issue, and have resolved it as follows:

  1. Clone your same project in some other folder.
  2. Copy the (hidden) .git folder of the cloned project.
  3. Finally replace the .git folder of the original project with the one that you’ve have copied.

Edit

Why does this happen?

  • Broken git repositories are often the result of file system corruption due to abrupt power failure or other abnormalities.
  • Since git stores all the information inside .git folder and if they are corrupted git can no longer recognize the repository.

Caveats

Everything in your previous .git folder will be gone. Configurations like remote reference name(s) must be set up again.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)