How to Rename a Remote Git Branch

February 4, 2023 / How-to Guide

In contrast to a local branch, a remote branch cannot be directly renamed. Instead, you will need to push a new branch name to the remote repository and delete the old remote branch name.

Follow the steps given below:

  1. To begin, you must use the “–m” option to rename a local branch.
  2. Next step is to push the new branch and remove the old one. Enter the following command to do this:
    git push origin --delete old-name
  3. Finish by rearranging your new local branch’s upstream branch:
    git push origin -u new-name
  4. You can rename a remote git branch by overwriting it with the following command:
    git push origin :old-name new-name
    git push origin –u new-name

You can rename a remote Git branch this way. The above steps are for renaming a remote git branch, you can also easily rename a local git branch.

We hope this helped you. For more information, contact our support staff.

Spread the love