I've tagged a commit with a lightweight tag, and pushed that tag to a remote repo, shared with other developers. I have now realised I should have annotated it so that it appears in git describe
.
Is there a way to convert it/re-tag the commit without breaking things?
To create an annotation tag you just need to add “-a” with the git tag command and “-m” to specify the message. $ git tag -a v1.
If the tag is an annotated tag, you'll see the message and the tag object, followed by the commit. If the tag is a lightweight tag, then you'll see only the commit object. If the current commit exactly matches that of a tag, then only the tag name is printed.
The difference between the commands is that one provides you with a tag message while the other doesn't. An annotated tag has a message that can be displayed with git-show(1), while a tag without annotations is just a named pointer to a commit.
To create a Git tag with a message, use the “git tag” command with the “-a” option for “annotated” and the “-m” option for message. Note : if you don't provide the “-m” option, your default text editor will open in order for you to type the tag message.
A lightweight tag is just a 'ref' that points at that commit. You can force-create a new annotated tag on top of the old tag:
git tag -a -f <tagname> <tagname>
As of Git v1.8.2, you need to use --force
to replace any tags on a remote with git push
, even if you are replacing a lightweight tag with something that is effectively a fast-forward or a true tag object pointing at the same commit as the existing tag reference.
git push --force origin <tagname>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With