Cheat Sheets · Git Cheat Sheet · Git Rename Remote Branch — Complete 3-Step Process
Git Rename Remote Branch — Complete 3-Step Process
git branch -m <old> <new>1. Rename the branch locally
git push origin -u <new>2. Push new branch and reset upstream tracking
git push origin --delete <old>3. Delete old branch on remote repository
Complete 3-step remote rename workflow
| Command | Step Description |
|---|---|
git branch -m <old> <new> | 1. Rename the branch locally |
git push origin -u <new> | 2. Push new branch and reset upstream tracking |
git push origin --delete <old> | 3. Delete old branch on remote repository |
Git has no direct "remote rename" command. The standard workflow is pushing the new branch name, setting upstream tracking, and deleting the old remote branch.
Related Git recipes
FAQ
Will this close existing Pull Requests?
Yes. If a PR was opened against the old branch name, renaming or deleting it closes or breaks the PR. Merge or update PR target first.
What should teammates do after a remote rename?
Collaborators should run: git fetch --prune and git checkout -b .
Can I rename the default branch (main/master)?
Yes, but change the default branch setting in your GitHub/GitLab repository settings first before deleting the old one.
Stop memorizing — build it interactively
Generate remote branch commands in the Git BuilderFull reference: Git Cheat Sheet