Annotated tags
Git has two kinds of tags; this is because in some situations you may want to add a message to the tag, or because you like to have the author stick to it.
We already have seen the first type, the simpler one; tags containing this extra information load belong to the second type, the annotated tag.
An annotated tag is both a reference and a git object such as commits, trees, and blobs.
To create one, simply append -a to the command; let's create another one to give this a try:
[8] ~/grocery (bug) $ git tag -a annotatedTag 07b1858
At this point Git opens the default editor, to allow you to write the tag message, as in the following screenshot:
Save and exit, and then see the log:
[9] ~/grocery (bug) $ git log --oneline --graph --decorate --all * 5d605c6 (HEAD -> bug) Another bug! * 07b1858 (tag: bugTag, tag: annotatedTag) Bug eats all the fruits! | * a8c6219 (melons) Add a watermelon | * ef6c382 (berries) Add a blackberry | * 0e8b5cf (master) Add an orange
|/
* e4a5e7b Add an apple * a57d783 Add a banana to the shopping list
Okay, there are two tags now on the same commit.
A new ref has been created:
[10] ~/grocery (bug) $ cat .git/refs/tags/annotatedTag 17c289ddf23798de6eee8fe6c2e908cf0c3a6747
But even a new object: try to cat-file the hash you see in the reference:
[11] ~/grocery (bug) $ git cat-file -p 17c289 object 07b18581801f9c2c08c25cad3b43aeee7420ffdd type commit tag annotatedTag tagger Ferdinando Santacroce <ferdinando.santacroce@gmail.com> 150376226 4 +0200 This is an annotated tag
This is how an annotated tag looks like.
Obviously, the git tag command has many other options, but I only highlighted the ones I think are worth knowing at the moment.
If you want to look at all the options of a command, remember you can always do a git <command> --help to see the complete guide.
Time to spend some words on the staging area, as we have only scratched the surface.