首页 > 解决方案 > 致命的:您当前的分支似乎已损坏

问题描述

使用时出现此错误

 git log

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

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

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

我在 git 中阅读了这个主题 Broken branch, fatal: your current branch 似乎已损坏

标签: gitgit-branchgit-bash

解决方案


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

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>

推荐阅读