In this article, we will see how to add remove and get the tags of a commit in git.
Tags allow us to mark specific commits with a meaningful labels. This can make it easier to identify important milestones in projects development history
Tags are a useful feature in Git that allow you to mark specific commits with a meaningful label.
How to add a tag to a Git commit:
To add a tag to a Git commit, you can use the git tag
command followed by the name of the tag and the hash of the commit.
Following is an example on how to add a tag to the commit:
git tag v1.0.0 6a30f54
The above command adds a tag called v1.0.0 to the commit 6a30f54
How to delete a tag from a Git commit:
To delete a tag from a Git commit, use the command git tag -d followed by the name of the tag.
Here’s an example on how to delete a tag:
git tag -d v1.0.0
How to get tags of a commit
To get the tags associated with a Git commit, use the git tag --contains
command followed by the hash of the commit.
Here’s an example:
git tag --contains 6a30f54
The above command displays the list of tags that contain in the commit 6a30f54.