Git 2 reference · Branching and Merging

git tag Command (Git)

Mark releases with lightweight or annotated tags, list them, and push them to a remote.

Git 2

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

git tag [-a] [-m MSG] NAME [COMMIT]   git tag -l [PATTERN]

Parameters

ParameterDescription
-a -m MSG Annotated tag with a message (recommended for releases).
-l 'v1.*' List matching tags.
-d NAME Delete a local tag.
git push origin NAME Publish a tag.

Examples

Annotated release tags
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git tag -a v1.0.0 -m 'First release'
echo v2 >> README.md; git commit -q -am 'Update'
git tag -a v1.1.0 -m 'Docs update'
git tag -l 'v1.*'
git describe --tags

Output

v1.0.0
v1.1.0
v1.1.0

Run this on your computer — see “Get Started” for setup.

An annotated tag is an object
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git tag -a v2.0.0 -m 'Big release'
git show v2.0.0 --format= --no-patch
git cat-file -t v2.0.0

Output

tag v2.0.0
Tagger: Ana Dev <[email protected]>

Big release
tag

Run this on your computer — see “Get Started” for setup.

Was this page helpful?