Tagging

Git Tag

Creating Tags

Git tag creates lightweight or annotated tags for commits.

Understanding Git Tags

Git tags are used to mark specific points in your repository's history. Typically, they are used to mark release points (e.g., v1.0, v2.0) and are very helpful in version control and release management processes. Git supports two types of tags: lightweight and annotated.

Creating a Lightweight Tag

Lightweight tags are simple pointers to a specific commit. They are quick to create and do not store additional information like the tagger's name, email, or date. Use the following command to create a lightweight tag:

This command creates a tag named v1.0 on the current commit. To create a tag on a specific commit, specify the commit hash:

Creating an Annotated Tag

Annotated tags, unlike lightweight tags, store additional metadata. This includes the tagger's name, email, date, and a message. They are recommended for tagging releases. Use the following command to create an annotated tag:

In this example, -a specifies that the tag is annotated, and -m allows you to add a message for the tag. You can also tag a specific commit by appending the commit hash to the command:

Viewing Tags in Your Repository

To list all the tags available in your repository, use the following command:

This will display a list of all the tags. To view the details of a specific annotated tag, you can use:

Pushing Tags to a Remote Repository

Tags are not automatically pushed to remote repositories. To push a specific tag to a remote repository, use:

To push all tags at once, you can use:

Deleting Tags

If you need to delete a tag, whether locally or remotely, you can use specific Git commands. However, this topic will be covered in detail in the next post, "Tag Delete."

Previous
Stash Drop