I created a tag and forgot to sign it, then pushed the tag to GitHub. Is it possible to just sign that tag retroactively, or do I have to create a new tag?
I have read the man page for git tag
and googled a bit, but have come up with no clues that adding a signature to an already existing tag is possible.
You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published. Tags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone.
It's easy to sign tags with the addition of the -s option to the git tag command. Remember that the tag will be assigned to the most recent commit. Well done!
We are required to delete/update branches or delete/update files etc. Similar to this, sometimes, we are required to update the tags in Git. Updating a tag will take your tag to another commit. For example, we can update the tag v1.
No you would need to::
replace it with a tag using the same name:
git tag <tag name> <tag name> -f -s
but first set the committer date, in order to not change the date
set GIT_COMMITTER_DATE="$(git log -1 --format=%aD <tag_name>)"
As mrts adds in the comments, since the tag was already pushed:
You also need to force push the updated tag with
git push origin <tag_name> -f
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