git tag command

Tags are pointers that refer to particular points in Git history. We can mark a particular moment in time with a tag.

There are two types of git tags, we can use: lightweight and annotated tags • lightweight tags are...lightweight. They are just a name/label that points to a particular commit. • annotated tagsstore extra meta data including the author's name and email, the date, and a tagging message (like a commit message)

Viewing Tags The git tag will print a list of all the tags in the current repository.

Bash

git tag or git tag -l

This command lists the tags in alphabetical order.

Creating Lightweight Tags To create a lightweight tag, use git tag <tagname> By default, Git will create the tag referring to the commit that HEAD is referencing.

Bash

git tag <tagname>

Replace <tagname> with the desired name for your tag.

Creating Annotated Tags
Use git tag -a to create a new annotated tag. Git will then open our default text editor and prompt us for additional information.

Bash

git tag -a <tagname>

Similar to git commit, we can also use the -m option to pass a message directly and forgo the opening of the text editor.

Bash

git tag -a <tagname> -m "Your tag message"