version-control - git rename file - How do I rename a local Git branch?

View 3+ more / git / git-branch

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

Sazzad Hissain Khan

Answer #1

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