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

前端 未结 9 1419
时光说笑
时光说笑 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:43

    You might encounter this error if you try to rename a branch into a namespaced (or folder) branch.

    If it happens, go to the directories .git/logs/refs/heads/ and .git/refs/heads/ , and you'll see your branch is now a folder with a file inside it.

    In both folders, move the file out to the folder's level, checkout that branch, delete the now empty folders and now you should be able to perform git checkout -b / without error, or git branch -M /.

提交回复
热议问题