Developer's Lab

By Diogo Pinto - DiØ

Rename Local and Remote Branch With Git

If you want rename a branch local and remote, follow these steps:

First, rename the target branch:

git branch -m new-name

Or, if by chance, you desire rename another branch, whose is not current branch, do it such as:

git branch -m old-branch-name new-branch-name

Second, remove remote branch and push the new local branch:

git push origin :old-branch-name new-branch-name

And finally, load the upstream branch for the new local branch:

git checkout new-branch-name
git push origin -u new-branch-name

Comments