How do I rename a branch?
Locally, in place. The remote keeps the old name until you deal with it.
A local branch can be renamed from the sidebar.
Renaming does not touch the remote. Locally the branch has a new name; on the server it still has the old one — and the renamed branch goes on tracking it, because a rename keeps the branch’s configuration. With Git’s default settings a push refuses to send a branch to an upstream with a different name, so the old connection has to go before the new one can be made.
To finish the job:
- Remove the old upstream: Remove Upstream, under Upstream Branch in the branch’s context menu. See the upstream branch.
- Push the branch. With no upstream, the push publishes it under its new name and tracks it from then on.
- Delete the old branch on the remote.