![Forrest logo](/images/logo.png)
git-tag:tldr:2968d
The git tag
command is used in Git to manage the tags in a repository. A tag in Git is a pointer to a specific commit, used to label a significant point in the repository's history, such as a release version or a production-ready commit.
When you run git tag
without any arguments, it lists all the tags in your repository. Each tag is displayed with its name, commit hash, and any associated message.
There are different ways to use the git tag
command:
-
Creating a lightweight tag:
git tag <tagname>
: Creates a new tag at the current commit, creating a lightweight or unsigned tag.git tag -a <tagname> -m <message>
: Creates an annotated tag, associating a message with the tag. This signed tag includes the name of the person who created it and the date.
-
Tagging a different commit:
git tag <tagname> <commit>
: Creates a new tag at a specified commit.
-
Deleting a tag:
git tag -d <tagname>
: Deletes a local tag. Note that this only removes the tag locally; it doesn't remove the associated commit or tags in other repositories.
-
Pushing tags to a remote repository:
git push origin <tagname>
: Pushes a specific tag to a remote repository.git push origin --tags
: Pushes all local tags to a remote repository.
-
Listing specific tags:
git tag -l "<pattern>"
: Lists tags that match a specific pattern.
Tags are immutable, meaning they do not change once created. They serve as references to specific points in history, enabling quick access to important commits or releases within a repository.