Skip to main content
Skip to main content

Luke Howsam

Software Engineer

How to rename local & remote git branches

Image of Git logo and Github octocat logo
Published
Share

How to rename a local Git branch

When you're working on a project, it's common to name your branches a certain way. It's easy to make a mistake when you name a branch so let's go over how to rename a branch.

Before you run the below commands, make sure you're on the branch you want to rename:

git checkout old-name

To rename a branch locally use the -m option:

git branch -m new-name

you will need to rename a local branch by following the previous steps:

  • Delete the old branch and push the new one:
git push -u origin --delete old-name

Reset the upstream branch for your new local branch and you're done!

git push -u origin new-name