Git Tag
In Git, a tag is a lightweight way to mark a specific version (commit) in the Git history. It is used to label a specific version with an easily readable name, such as v1.0, so that it can be referred to later.
There are two types of tags in Git: lightweight and annotated.
Lightweight tags: A lightweight tag is a simple reference to a specific commit, just like a branch. It’s a pointer to a specific commit and doesn’t contain any additional information such as author, date, or message.
Annotated tags: An annotated tag is a more complete and robust way of tagging a commit. It contains information such as the tagger’s name, email, date, and a message describing the purpose of the tag. Annotated tags are stored as full objects in the Git database.
In general, annotated tags are preferred over lightweight tags as they provide a more complete and reliable way to label a specific version in the Git history.
Both types of tags can be used to label a specific version, mark a release, or even to provide a way to roll back to a specific version in case of an issue.
Lightweight tags :
Lightweight tags in Git are a simple way to label a specific commit in the Git history. They are just a reference to a specific commit and don’t contain any additional information such as author, date, or message.
Lightweight tags can be created using the “git tag” command followed by the tag name:
$ git tag <tag name> $ git tag projectv1.0

Using the below command , you can the tag list .
$ git tag
Lightweight tags can be pushed to a remote repository just like branches using the “git push” command:
$ git push origin v1.0Lightweight tags provide a quick and easy way to label a specific version in the Git history, but they are less robust than annotated tags and don’t provide the same level of context and information. They are also not as secure as annotated tags, as there is no information about the tagger or date included with the tag.
In general, it is recommended to use annotated tags instead of lightweight tags for a more complete and robust way to label a specific version in the Git history.
Annotated tags :
Annotated tags are a more complete and robust way to tag a specific commit in Git. They are stored as full objects in the Git database, including information such as the tagger’s name, email, date, and a message describing the purpose of the tag.
An annotated tags can be created using the “git tag” command with the “-a” option followed by the tag name, and the message:
$ git tag -a v1.0 -m “This is my first annotated tag”![]()
Annotated tags can be pushed to a remote repository just like branches using the “git push” command:
$ git push origin v1.0Annotated tags provide a more complete way to label a specific version in the Git history, making it easier to identify the purpose and context of a tag. They also provide a way to verify the authenticity of a tag, as the tagger’s identity and the date of the tag can be stored as part of the tag information.
Difference between Annonated tags and Light-weighted tags :
The main difference between annotated tags and lightweight tags in Git is the amount of information they contain and store in the Git database.
Annotated tags: Annotated tags are stored as full objects in the Git database and contain additional information such as the tagger’s name, email, date, and a message describing the purpose of the tag. Annotated tags are more complete and provide a way to verify the authenticity of a tag. They are also more robust, as they provide more context and information about a specific version in the Git history.
Lightweight tags: Lightweight tags are simply a reference to a specific commit, just like a branch. They don’t contain any additional information such as the tagger’s name, email, date, or a message. Lightweight tags are quick and easy to create, but they are less secure and provide less context and information about a specific version in the Git history.
In general, it is recommended to use annotated tags instead of lightweight tags for a more complete and robust way to label a specific version in the Git history.
In order to delete a tag , use the following command
$ git tag -d <tag name>
To delete the tag in the remote from the local, use the following command
$ git tag origin -d <tag name>