Renaming Git branches
Following are some quick notes on how to rename a branch in Git, both remotely and locally. In the following examples we are renaming the branch old-name to new-name by copying the branch and then deleting the original. These notes assume you have one remote called origin.
Remotely duplicate the branch §
Copy the local branch old-name to origin, and rename it to new-name.
git push origin old-name:new-nameLocally checkout the new branch §
Configure a local branch which tracks the branch new-name at origin.
git branch new-name origin/new-name
git checkout new-nameLocally delete the old branch §
Delete the old branch locally.1
git branch -d old-nameRemotely delete the old branch §
Delete the old branch remotely (at origin).1
git push origin -d old-name