

Git Tag is a powerful way of organising your git commits and history by setting markers in your git history.
In this thread, I'm going to cover everything you need to know about it and how to use it.
Let's get started.



By creating a tag in your git database, you're referencing a certain commit.
An example of using tags is marking specific releases of a codebase. E.G. V1.0
For example, when I've redesigned my website, I tag the different versions first commit. 2/11

To create a new tag, you use the syntax:
git tag <TAG NAME>
So an example would be:
git tag V1.0
This would create a new tag that is called V1.0 and references the current commit reference that HEAD is pointing to. 3/11

You get to 2 different types of tags:


Generally, it is prefered to use Annotated tags. 4/11

To list all of the tags in a current git database, use the command:
git tag
This will return all of the tags within the database.
You can also filter them using wildcards:
git tag -l <WILDCARD>
5/11

By default, the tag will point to the current commit ref that HEAD is pointing to.
You can change this by passing a specific commit ref to the command:
git tag -a v1.2 <COMMIT REF>
This will create a new annotated tag with the passed ref.
6/11

If you try to create a duplicate tag name, git will error:
fatal: tag <TAG NAME> already exists
This also true if you point the tag at an old commit ref.
If you have to update an existing tag, use -f.
git tag -a -f v1.4 <COMMIT REF>
7/11

Like branches, git will not push tags, if you want to do this you have to explicitly pass it to git push:
git push origin <TAG NAME>
If you want to push multiple tags, you can use the --tags flag.
8/11

You can check out a tag using:
git checkout <TAG NAME>


You can easily delete a tag by using the -d flag like:
git tag -d <TAG NAME>
10/11
I hope you found this thread helpful. If you did please consider sharing it so others can find it helpful too.
If you like this content and want to see more, please consider following me.
11/11
If you like this content and want to see more, please consider following me.

11/11