I don\'t want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.
How can I rename a local branch wh
I foolishly named a branch starting with a hyphen, and then checked out master. I didn't want to delete my branch, I had work in it.
Neither of these worked:
git checkout -dumb-name
git checkout -- -dumb-name
"s, 's and \s didn't help either. git branch -m doesn't work.
Here's how I finally fixed it. Go into your working copy's .git/refs/heads, find the filename "-dumb-name", get the hash of the branch. Then this will check it out, make a new branch with a sane name, and delete the old one.
git checkout {hash}
git checkout -b brilliant-name
git branch -d -- -dumb-name