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:
- To begin, you must use the “–m” option to rename a local branch.
- 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
- Finish by rearranging your new local branch’s upstream branch:
git push origin -u new-name
- 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.