How to Rename a Local Branch in Git
Renaming local branches in Git is very easy. If you want to rename the current HEAD branch, you can use the following command:
$ git branch -m <new-name>
If you want to rename a different local branch (that is NOT currently checked out):
$ git branch -m <old-name> <new-name>
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
How to Rename a Remote Branch in Git
Renaming remote branches is a tiny bit more complicated. To be precise, it's not directly possible. In practice, renaming a remote branch is done by simply deleting the old one and then pushing / recreating a new one:
# First, delete the current / old branch:
$ git push origin --delete <old-name>
# Then, simply push the new local branch with the correct name:
$ git push -u origin <new_name>
Tip
Renaming Branches in Tower
In case you are using the Tower Git client, you can rename both local and remote branches simply from the contextual menu (no need to delete and re-push anything):
Learn More
- Check out our command overview on git branch
- More frequently asked questions about Git & version control