How to rename a local Git branch?


How can I rename a local branch which hasn't been pushed to a remote branch?

1 Answer

Rename the current branch:

git branch -m <newname>

Rename a branch while pointed to any branch:

git branch -m <oldname> <newname>

The easy way to remember this branch -m by creating git alias. Use following command to create git alias:

git config --global alias.rename 'branch -m'

Now you can use:

git rename <newname>
# or
git rename <oldname> <newname>

Please login or create new account to participate in this conversation.