How to push tags in Git

Greg Foster
Greg Foster
Graphite software engineer

A Git tag is a reference that points to a specific commit in a Git repository. Tags are typically used to capture a snapshot of a project at a particular point in time, such as at the release of a version. Tags can be either lightweight (a pointer to a specific commit) or annotated (a full object in the Git database containing the tagger's name, email, tagging date, and a tagging message).

This guide provides an in-depth look at how to use tags effectively, including how to add, push, and manage tags in your Git repository.

Before you can push a tag to a remote repository, you must create it locally:

  1. Lightweight tag: This is simply a pointer to a specific commit.

    git tag v1.0

    Running this command will create a tag pointing to the commit that is currently checked out on your local branch.

  2. Annotated tag: This is a more detailed tag that includes additional information such as the author, date, and message.

    git tag -a v1.0 -m "Release version 1.0"

These command also creates a tag pointing to the latest commit on your current branch. If you want to tag a previous commit, you can specify the commit hash at the end of the command.

Once you have created your tags locally, you need to push them to a remote repository to share them with other team members.

  1. Push a single tag

    To push a single tag to your remote repository, run:

    git push origin v1.0

    This command pushes the v1.0 tag to the remote named origin.

  2. Push all tags: If you want to push all your local tags to the remote repository, use:

    git push --tags

    This will transfer all tags that you have locally that are not already in the remote repository.

If you're working with multiple remotes, you might need to specify which remote you want to push your tags to. The syntax remains straightforward:

git push remote-name tag-name

Replace remote-name with the name of the remote repository (e.g., origin, upstream) and tag-name with the name of the tag you want to push.

Sometimes you may need to update a tag after it has been altered locally. By default, Git does not allow you to update tags that have already been pushed because this can cause issues for others who have already fetched the tag. However, you can force push a tag if necessary:

  1. Force push a single tag: To force push a single tag, use:

    git push --force origin v1.0

    This command forcefully updates the v1.0 tag at the remote named origin.

  2. Force push all tags: Similar to pushing all tags, you can force update all tags:

    git push --force --tags

This should be used with caution as it can overwrite changes in the remote repository that have not been synchronized.

For further reading on tags in Git, see the official Git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2