Giulia Chiola
Posted on • Originally published atgiuliachiola.dev
How to rename a git branch
Rename local branch
To rename alocal branch in git
- Move on the branch you want to rename
git checkout-b feature/wrong-name
- Rename it locally
git branch-m feature/new-awesome-name
⚡️ Bonus tip
If you haveohmyzsh installed, you can use its shortcut
gbm
.
Rename remote branch
To rename aremote branch is quite longer:
- Unset the upstream branch to unlink local and remote branch
git branch--unset-upstream
Note: if you followed the previous step, you don't have to delete local branch because you have already renamed it!
- Update the upstream branch to the new one and push it
git push--set-upstream origin feature/new-awesome-name
- Delete remote branch
git push origin--delete feature/wrong-name
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse