DEV Community

Bibek Mani Acharya
Bibek Mani Acharya

Posted on • Originally published at techradiant.com

How to rename git branch local and remote

If you want to rename a local branch even if you have already pushed it to remote, follow the following steps.

Rename your local branch
If you are on the branch you want to rename
git branch -m new_name

If you are on a different branch
git branch -m old_name new_name

Delete the old remote branch and push the new local branch with new name
git push origin :old_name new_name

Reset the upstream branch for the new name local branch
git push origin -u new_name

Top comments (0)