DEV Community

Dênis Mendes
Dênis Mendes

Posted on • Edited on

Tag on Git

Tag is a nice way to keep system versions clear and arranged.
I like to tag my commits after I did them so I do tag like that:

First I run:

git log to see the commit checksum that I'll tag.

After I run:

git tag -a v1.2 9fceb02

Where 9fceb02 is my commit checksum.

So we have a new tag but it's only locally yet. Then I run:

git push --tags

Done!

If you need to see which tags were created you can run:

git tag

UPDATE I:
So some day you want to see the source code to the tag v1.2 what you need to do is that:

git checkout tags/v1.2

Now you're going to be able see the source code from tag v1.2.

UPDATE II:
You can see the log for a tag as well:

git log v1.2

Do you want to know more? Look at: https://git-scm.com/book/en/v2/Git-Basics-Tagging

UPDATE III:

I needed to remove a tag which I related with the wrong commit reference so I did that:

git push origin :tag_name

and also:

git tag --delete tag_name (it goes to delete locally)

Top comments (0)