Expand description
In Git objects there are two types of tags: Lightweight tags and annotated tags.
A lightweight tag is simply a pointer to a specific commit in Git’s version history,
without any additional metadata or information associated with it. It is created by
running the git tag command with a name for the tag and the commit hash that it points to.
An annotated tag, on the other hand, is a Git object in its own right, and includes
metadata such as the tagger’s name and email address, the date and time the tag was created,
and a message describing the tag. It is created by running the git tag -a command with
a name for the tag, the commit hash that it points to, and the additional metadata that
should be associated with the tag.
When you create a tag in Git, whether it’s a lightweight or annotated tag, Git creates a new object in its object database to represent the tag. This object includes the name of the tag, the hash of the commit it points to, and any additional metadata associated with the tag (in the case of an annotated tag).
There is no difference in binary format between lightweight tags and annotated tags in Git, as both are represented using the same lightweight object format in Git’s object database.
The lightweight tag is a reference to a specific commit in Git’s version history, not be stored as a separate object in Git’s object database. This means that if you create a lightweight tag and then move the tag to a different commit, the tag will still point to the original commit.
The lightweight just a text file with the commit hash in it, and the file name is the tag name. If one of -a, -s, or -u <key-id> is passed, the command creates a tag object, and requires a tag message. Unless -m <msg> or -F <file> is given, an editor is started for the user to type in the tag message.
4b00093bee9b3ef5afc5f8e3645dc39cfa2f49aaThe annotated tag is a Git object in its own right, and includes metadata such as the tagger’s name and email address, the date and time the tag was created, and a message describing the tag.
So, we can use the git cat-file -p <tag> command to get the tag object, and the command not
for the lightweight tag.
Structs§
- Tag
- The tag object is used to Annotated tag