Git Tag Mini Cheat Sheet

Just as a kind of mini cheat sheet for using git tags:

Adding a tag:

  • git tag tag_name
  • git tag
    Should show your new tag.
  • git push origin --tags or git push origin :tag_name
    Because git push doesn’t push tags.

Removing a tag:

  • git tag -d tag_name
  • git tag
    Should no longer show your tag.
  • git push origin :refs/tags/tag_name
    Because git push --tags doesn’t push deleted tags.


Hope that helps.

  • Twitter
  • Digg
  • del.icio.us
  • DZone
  • Reddit
  • email

2 Responses to “Git Tag Mini Cheat Sheet”

  1. Jörg W Mittag says:

    Git actually has three different kinds of tags: lightweight local tags, annotated tags and signed tags. The ones you are describing are lightweight tags. They are meant for local throwaway use by a single developer, which is why they are neither pushed nor fetched by default. The next step up is an annotated tag, created with git tag -a. In addition to just having a name, it also has an associated message, typically it contains a description of *why* this particular tag is interesting, e.g. in the case of a release, it contains the release announcement so that people who only follow the repo but not the mailinglists get the gist of what’s going on. It is meant for public tags, i.e. tags that are of interest to the entire community, not just to the owner of the repository. Consequently, they are pushed and fetched by default. Lastly, signed tags are basically annotated tags that are digitally signed with an OpenPGP signature. These are typically used for releases. Signed tags are the typical way to establish trust in a Git repository: while the SHA-1s guarantee the integrity of the repository, only the signature can provide trust. They, too, get pushed and fetched automatically.

  2. Great explanation Jörg! Thanks! However, I never noticed annotated and signed tags getting pushed automatically. Can you elaborate on that?

Leave a Reply