git rename a branch (local and remote)
Quick Answer
# Rename the current branch
git branch -m new-name
# Push the new name and set upstream
git push origin -u new-name
# Delete the old remote branch
git push origin --delete old-name
When to use this
You want to rename a branch — for example to follow a new naming convention or fix a typo.
Other causes & fixes
Rename a branch you are not currently on
git branch -m old-name new-name
Update other teammates after renaming
Others with the old branch checked out need to reset their upstream reference:
git fetch origin
git branch -u origin/new-name new-name
Related