Skip to content

Git tags

A tag points to a specific commit in a repository. It is often used to label a release or version of code, so that it may be referred to later.

An annotated tag also contains a date, tagger and message. A lightweight tag only includes the commit.

To add or create an annotated tag, gather or decide on

  • The name of the tag, e.g. the version number
  • A message describing the tag
  • The commit hash, or make sure the repo’s HEAD is at the commit you want to tag.

Then run

Terminal window
git tag -a -m 'first release' v1.0.0

The tag will only existing in the local repo. To distribute the tag, it must be pushed.

Terminal window
git push --tags

To see all tags in a repo, run

Terminal window
git tag

To delete a tag run

Terminal window
git tag -d v1.0.0

Before doing this, consider how the tag is being used and whether a new tag is more appropriate.