Broken branch in git, fatal: your current branch appears to be broken

前端 未结 9 1290
时光说笑
时光说笑 2021-02-01 12:57

Here is my case:

  • I was working on one branch.
  • Pushed new commits to the remote.
  • Switched back to the master branch.

But suddenly

9条回答
  •  孤街浪徒
    2021-02-01 13:30

    In may case after using Notepad to open the file named after my branch name found at .git\logs\refs\heads\ was empty. So I deleted it.

    and run to get latest commit

    git reflog
    

    4404dd7 HEAD@{0}: commit: update README

    and then I run

    git reset --hard 4404dd7 
    

    HEAD is now at 4404dd7 update README

    and branch was back. Note

    This may diverge your branch. So you may need to fix them later.

    4404dd7 was my latest commit in that branch and I don't know if this is proper solution or not but it was what worked or me.

提交回复
热议问题