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

fatal: your current branch appears to be broken

我在使用

时出现这个错误
 git log

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

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

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

我读了这个话题 Broken branch in git, fatal: your current branch appears to be broken

终于,在非常痛苦之后,这对我有用

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>