A blog for technology, SEO tips, website development and open source programming.

How To Rename a Local and Remote Git Branch

0 2,305

You are collaborating on a project with a group of people, and you have defined a naming convention for git branches. You created a new branch , pushed the changes to the remote repository, and realised that your branch name was incorrect. Check this post on How To Rename a Local and Remote Git Branch,

Luckily, Git allows you to rename the branch very easily using the git branch -m command.

This guide explains how to rename local and remote Git branches.

Don’t miss out 👇
Which 3 attributes your images must have?

Renaming Git Branch

Follow the steps below to rename a Local and Remote Git Branch:

  1. Start by switching to the local branch which you want to rename:
    git checkout <old_name>
  2. Rename the local branch by typing:
    git branch -m <new_name>
    At this point, you have renamed the local branch.If you’ve already pushed the <old_name> branch to the remote repository , perform the next steps to rename the remote branch.
  3. Push the <new_name> local branch and reset the upstream branch:
    git push origin -u <new_name>
  4. Delete the <old_name> remote branch:
    git push origin --delete <old_name>

That’s it. You have successfully renamed the local and remote Git branch.


Branches are part of the software development process and one of the most powerful features in Git. Branches are essentially pointers to a certain commit.

Renaming a local Git Branch is a matter of running a single command. However you can’t directly rename a remote branch, you need to push the renamed local branch and delete the branch with the old name.

If you hit a problem or have feedback, leave a comment below.

Follow me on Instagram

😉  That’s it for now. 

If you liked this article, then please subscribe to my YouTube Channel for video tutorials.

You can also find me on Twitter and Facebook.

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More