8

Suppose I have committed an annotated tag and pushed it.

  1. Can I delete it from the remote (& if so how)?
  2. What are the safety implications of deleting it - i.e. in what situations will it break stuff?
  3. Is any of that changed if I have already committed other normal commits after it (are annotated commits leaf nodes or do they have children?).

From git docs:

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

This mention to "lightweight tags" as "temporary tags" makes me wonder if the process to delete "annotated tags" would be different.

  1. Are the steps to delete a "annotated tag" the same for an "lightweight tag" or anything else is neeed?
formigarafa
  • 377
  • 1
  • 11
Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • The answers in the linked answer will delete the ref. The tag object will remain until garbage collection, or forever if the remote never prunes objects. – Guildenstern May 19 '23 at 13:39

1 Answers1

7

You can delete the tag locally like so

git tag -d tag_name 

And then to delete it from the remote, you do

git push --tags remote_name :tag_name

It won't break anything git specific but it will mess things up that rely on the tag being there (e.g release management tools etc.)

It won't affect subsequent commits since the tag itself just a reference and not an object.

Louis CAD
  • 10,965
  • 2
  • 39
  • 58
Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169