Forrest Forrest - 1 year ago 78
Git Question

How to rename a local Git branch?

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

Instead, I want to use the simplest way to rename a local branch, which hasn't been pushed to a remote branch.

Answer Source

If you want to rename a branch while pointed to any branch, do :

git branch -m <oldname> <newname>

If you want to rename the current branch, you can do:

git branch -m <newname>

A way to remember this, is -m is for "move" (or mv), which is how you rename files.