Rename a local or remote Git branch
Rename a branch locally, publish the new name, and update collaborators, pull requests, and branch-specific configuration.
Use git branch -m NEW_NAME to rename the current local branch. At the Git protocol level, changing a remote branch name is usually a create-and-delete operation. Hosting services may offer a dedicated rename workflow that also updates platform metadata.
Rename locally and publish the new name
git switch old-name
git branch -m new-name
git push -u origin new-name
You can rename another local branch with git branch -m old-name new-name. The normal form refuses to overwrite an existing branch name; do not use force-renaming merely to bypass a name collision you have not investigated.
After confirming the new remote branch, updating dependent configuration, and coordinating with collaborators:
git push origin --delete old-name
The local rename preserves the branch's commit identity and moves its relevant configuration and reflog. A branch that was never published needs no remote operation.
Update another clone
A collaborator who has the old local branch can retain its local work while renaming it:
git branch -m old-name new-name
git fetch origin --prune
git branch --set-upstream-to=origin/new-name new-name
Resolve any existing new-name branch first. Someone without a corresponding local branch can instead create it with git switch --track origin/new-name after fetching. Pruning removes stale remote-tracking refs; it does not delete a collaborator's local branch or merge their commits.
Check hosting-platform behavior
For a default or protected branch, prefer the hosting service's documented rename procedure. GitHub updates several associated settings and links, but its behavior depends on whether the renamed branch is a pull request's base or head. Renaming the head branch of an open pull request can close that request. A raw push-and-delete sequence is not equivalent to the platform's rename operation.
Review open pull requests before changing names. Also inspect Actions or other CI triggers, branch protections and rulesets, deployment settings, documentation links, and external integrations. GitHub's redirects do not cover every kind of URL or Git operation.
Team considerations
Use a brief coordinated migration when the branch is shared. Tell collaborators the old and new names, when the old remote branch will be removed, and how to update their upstream. For a default-branch change, refresh the remote's default-branch information in existing clones if needed.
A consistent naming convention reduces churn, but renaming does not require rewriting commits. Treat the branch name as an interface used by people and automation, and test those references after the rename.
See git-branch, git-push, and GitHub's branch rename behavior.
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan