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
Syntax
git tag [-a] [-m MSG] NAME [COMMIT] git tag -l [PATTERN]
Parameters
| Parameter | Description |
|---|---|
-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
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.
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.
Related
git log· Show commit history: one line per commit, as a graph, filtered by author, date, path or message.git push· Upload local commits and tags to a remote branch; -u sets the upstream, and --force-with-lease rewrites history safely.- Remotes: clone, fetch, pull and push · tutorial