Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

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

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.