# git tag: Usage, Options & Common CI Errors

> git tag creates and lists tags for releases. Reference for -a, -m, -d, pushing tags, and the "tag already exists" and missing-tag errors in release CI.

Source: https://latchkey.dev/learn/command-reference/git-tag  
Updated: 2026-06-25

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

| Flag | What it does |
| --- | --- |
| -a / --annotate | Create an annotated tag |
| -m <msg> | Tag message (implies annotated) |
| -d / --delete | Delete a tag locally |
| -l / --list <pattern> | List tags matching a pattern |
| -f / --force | Move 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.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git tag: Usage, Options & Common CI Errors?

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 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
