Git Rename Branch
·
Upd.
•
By
Jasper Frumau
DevOps
To rename a git branch, for example when one branch is too far behind and you quickly add a new one, you can rename your branch locally, remove it on remote and then upload the renamed branch as a new one. You can do that using this code
git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
props lttlrck
The command with --
git checkout k8 --
may be needed to switch to new branch locally due to error
fatal: 'k8' could be both a local file and a tracking branch. Please use -- (and optionally --no-guess) to disambiguate
This happened when we recreated the same branch and tried to use it locally.
Need Help with a Sage or WordPress Project?
We work with agencies and freelance developers on Sage theme builds, WordPress migrations, and white-label development. Whether you need hands-on help or just a second opinion on architecture, we’re available for short-term and ongoing engagements.
- Sage 10 / 11 theme builds and migrations
- Composer, Vite, and build process troubleshooting
- White-label WordPress development for agencies
- Code reviews and technical consulting
Comments are closed for this post.