Broken branch in git, fatal: your current branch appears to be broken Broken branch in git, fatal: your current branch appears to be broken git git

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 5917fefd485f655ab369d4e9eeda3c157c03f514commit$ git cat-file -p 5917fefd485f655ab369d4e9eeda3c157c03f514tree b75cab3c54b780075b312be3e878b389a2baf904parent 8235189aa22169295243d295fb1cc2ff2f8f7cd5author Ilker Cat <ilker.cat@blabla.com> 1495136738 +0200committer Ilker Cat <ilker.cat@blabal.com> 1495136738 +0200

The second output is what a commit object basically contains. Try to check whether the commit object in your master branch under .git\refs\heads\master and its tree and parent SHA-1 keys are not corrupted.

Even some apostrophes inside your master branches file will lead into a "broken branch". It must contain only the lastest commits object SHA-1 hash and nothing else.


You might encounter this error if you try to rename a branch into a namespaced (or folder) branch.

If it happens, go to the directories .git/logs/refs/heads/<name> and .git/refs/heads/<name> , and you'll see your branch is now a folder with a file inside it.

In both folders, move the file out to the folder's level, checkout that branch, delete the now empty folders and now you should be able to perform git checkout -b <name>/<subname> without error, or git branch -M <name>/<subname>.