fatal:您当前的分支似乎已损坏

yas*_*s17 5 git git-bash git-branch

我使用时出现此错误

 git log
Run Code Online (Sandbox Code Playgroud)

fatal:您当前的分支似乎已损坏

我的分支文件损坏了我在记事本中打开了 .git/refs/heads/mybranch 但我只看到了一些????????? 在文件中

我知道我必须找到分支哈希并将其复制到 .git/refs/heads/mybranch 文件中,但我不知道如何找到该哈希

我读了这个主题 git 中的分支已损坏,致命:您当前的分支似乎已损坏

yas*_*s17 17

最后,经过非常痛苦,这对我有用

1 get backup from your .git directory
2 open file .git\logs\refs\heads\<branch name> with your editor 
3 copy second hash of your last line
4 open file .git\refs\heads\<branch name> and delete everything in this file
5 past that hash to .git\refs\heads\<branch name>
Run Code Online (Sandbox Code Playgroud)