Skip to content
Latchkey

git tag: Usage, Options & Common CI Errors

git tag marks a specific commit, usually a release, with a permanent name.

Tags are how release pipelines pin versions. Remember that tags are not pushed by default.

What it does

git tag creates a lightweight or annotated tag pointing at a commit. Annotated tags (-a) store a tagger, date, and message; lightweight tags are just a name.

Common usage

Terminal
git tag                       # list tags
git tag v1.2.0                # lightweight tag on HEAD
git tag -a v1.2.0 -m "Release 1.2.0"
git push origin v1.2.0        # tags are NOT pushed by default
git tag -d v1.2.0             # delete locally

Options

FlagWhat it does
-a / --annotateCreate an annotated tag
-m <msg>Tag message (implies annotated)
-d / --deleteDelete a tag locally
-l / --list <pattern>List tags matching a pattern
-f / --forceMove an existing tag

Common errors in CI

fatal: tag 'vX' already exists - re-tagging needs -f, and the remote tag also needs git push --force origin vX (or delete-then-push). Tags missing on the runner usually means a shallow clone or that git fetch --tags was not run; set fetch-depth: 0.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →