How do I edit an existing tag message in Git?
We have several annotated tags in our Git repository. The older tags have bogus messages that we would like to update to be in our new style.
% git tag -n1
v1.0 message
v1.1 message
v1.2 message
v2.0 Version 2.0 built on 15 October 2011.
In this example, we would like to make v1.x messages look like the v2.0 message. How would we do this?
git tag <tag name> <tag name>^{} -f -m "<new message>"
This will create a new tag with the same name (by overwriting the original).
To update a complex message, just specify the annotated tag option with -a
or the signed tag option with -s
:
git tag <tag name> <tag name>^{} -f -a
This will open an editor with the contents of your old tag message.
git tag <tag name> <tag name>^{} -f -a
This is an improvement: without ^{}
it will create a new tag object that reference the old tag object, where both of them will have the same tag name.
<tag name>^{}
will resolve the tag/reference until it finds the first commit hash.