Delete broken branch in git

git

Solution

If `git branch -D` really isn't working, then your only option is to side-step it and edit the git check-out's state yourself. You should go to the root-directory of your check-out (where the `.git` directory is) and

- edit `.git/packed-refs`; if you see a line with your branch name then delete it

- look in `.git/refs/heads` for a file named after your branch; if you see one, delete it

Problem

I have created branch with "git checkout -b mybranch". It seems that something went wrong, and now I can't delete it using "git branch -D mybranch". It says: error: branch 'mybranch' not found.

Original source