Since I keep forgetting the difference and order between renaming branches and tags.
Note you need to repeat the origin
steps for each remote!
[WayBack] How to rename git local and remote branches:
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
Like tags below, be aware of the implications when renaming branches: if you pushed before other users already can have the old branch and have acted upon it.
[WayBack] git tag – How do you rename a Git tag? – Stack Overflow:
old^{}
git tag -d old
git push origin :refs/tags/old
git push origin refs/tags/new
Be aware, of the [WayBack] implications that a Git Tag change has to consumers of a package!
Note the first step is not just a plain git tag new old
The reason is that this will create a tag new
pointing to the tag old
, failing to point to the actual commit behind old
. A more detailed explanation, including how to better handle renames, is at [WayBack] git tag – Why isn’t my tag listed when I checkout with Git GUI? – Stack Overflow
–jeroen