2011-05-19

Git: Lightweight tags VS annotated tags


There are a two main types of tags in Git - lightweight and annotated. Lightweight tags are very much like branches that don’t change - it’s just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They are checksummed, contain the tagger name, email and date, have a tagging message and can be GPG signed and verified. It’s generally recommended to 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 that other information, lightweight tags are available too. -- GitHub

Create a lightweight Git tag:
git tag TagName
Create an annotated Git tag:
git tag -a -m 'optional tag comment' TagName
(If you omit the -a flag but still add a comment using -m, you're still creating an annotated tag!)
List Git tags:
git tag
Show Git tag content:
git show TagName
Delete a Git tag:
git tag -d TagName