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
.
Locally checkout the new branch §
Configure a local branch which tracks the branch new-name
at origin.
Locally delete the old branch §
Delete the old branch locally.1
Remotely delete the old branch §
Delete the old branch remotely (at origin).1