Forrest logo
back to the git tool

git-tag:tldr:2968d

git-tag: List all tags.
$ git tag
try on your machine

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:

  1. 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.
  2. Tagging a different commit:

    • git tag <tagname> <commit>: Creates a new tag at a specified commit.
  3. 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.
  4. 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.
  5. 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.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool