How to use Tags in Git?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:19
  1. Sometimes we might want to designate a certain commit as one of significance, for example, a certain released version. We can do this using Git tags.
    • Add tags to certain commits with messages.
    • Push the tags to remote repositories.
    • Show the commit a tag points to.
  2. What are Tags? – Tags can be used to mark significant commits with a meaningful string value. For example, a commit can be tagged as a release with a tag of v1.0.0 or something similar.
  3. Using Tags in Git –
    • git tag – Lists all the tags in the repository.

  • git tag --list <glob> - Shows all the tags matching the glob patterns.
  1. Two types of tags in git – lightweight and annotated.
  2. Lightweight tags are immovable static pointers to a commit. Created using git tag v1.1. Annotated tags contain more information, for example, a message, author, and date.
  3. Created bypassing the –a flag to git tag: For example, - git tag –a v1.1 –m ‘my message’
  4. To share tags with others, you need to specifically push them to the repository using git push <tag name> or git push --tags.
  5. Some examples,
    • git tag “1.0”


  • git show “22.0”

  • git tag –a “1.1” –m “This is my new annotated tag.”         
  • Git show “1.1”
  • Git push origin 1.1 – push to origin remote.
  • Git push origin --tags