git中的分支断开,致命:您当前的分支似乎已断开 [英] Broken branch in git, fatal: your current branch appears to be broken

查看:372
本文介绍了git中的分支断开,致命:您当前的分支似乎已断开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的情况:

  • 我当时在一个分支机构工作.
  • 将新提交推送到远程.
  • 切换回master分支.

但是在输入git checkout master命令之后,我的计算机突然遇到了蓝屏​​死机和意外的情况强行关闭发生了.重新启动计算机后,我检查了当前分支的状态,结果将每个文件都标记为新文件.

But suddenly after typing git checkout master command my computer encountered blue screen of death and an unexpected force shut down happened. After starting back my computer I have checked the status of my current branch and as a result I got each and every file as marked new files.

现在,我被困在这一点上,并且在git log命令后出现错误

Now, I am stuck at this point and after git log command I am getting error

$ git log
fatal: your current branch appears to be broken

如何解决此问题并恢复我的分支?

How to solve this problem and recover my branch?.

我正在使用Windows 7和git bash最新版本

I am working with windows 7 and git bash latest version

我不想删除此分支.

推荐答案

我在Windows 7上遇到了类似的问题.就我而言,\.git\refs\heads下的当前分支文件(由引用)已损坏.

I meet similar issue on Windows 7. In my case,the current branch file (refer by ./git/HEAD) under \.git\refs\heads was broken.

我在.git\logs\refs\heads上找到了具有相同分支名称的断开的当前分支的哈希码.

I found the hash code of broken current branch on .git\logs\refs\heads with same branch name.

然后通过记事本打开文件(.git\logs\refs\heads\xxx)并将第4个数字(哈希码)复制到(.git\refs\heads\xxx)

And I fixed the issue by opening that file (.git\logs\refs\heads\xxx) via notepad and copy the 4th number (the hash code) to (.git\refs\heads\xxx)

这篇关于git中的分支断开,致命:您当前的分支似乎已断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆