html tool

2017年12月18日星期一

git 修复 “”fatal: your current branch appears to be broken“”

https://stackoverflow.com/questions/33012869/broken-branch-in-git-fatal-your-current-branch-appears-to-be-broken


I meet similar issue on Windows 7. In my case,the current branch file (refer by ./git/HEAD) under \.git\refs\heads was broken.
I found the hash code of broken current branch on .git\logs\refs\heads with same branch name.
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)

The files in .git\refs\heads directory are your branches. Check those files. They should contain only a single commit objects SHA-1 hash. This hash is your latest commits SHA-1 key and your HEAD at the same time.
Copy the SHA-1 key and type
$ git cat-file -t 5917fefd485f655ab369d4e9eeda3c157c03f514
commit

$ git cat-file -p 5917fefd485f655ab369d4e9eeda3c157c03f514
tree b75cab3c54b780075b312be3e878b389a2baf904
parent 8235189aa22169295243d295fb1cc2ff2f8f7cd5
author Ilker Cat  1495136738 +0200
committer Ilker Cat  1495136738 +0200
【popexizhi: 查了一下,自己也是相同的问题,重新拷贝一下对应的文件就ok了】

没有评论:

发表评论