A Mutable Log

A blog by Devendra Tewari


Project maintained by tewarid Hosted on GitHub Pages — Theme by mattgraham

git tag

This post summarizes some useful tag related commands. All commands assume a tag with value v1.0.0, a version number. To create an annotated tag

git tag -a v1.0.0 -m "a comment"

To list all tags

git tag

To view details and diff for a tag

git show v1.0.0

To delete a tag

git tag -d v1.0.0

To replace a tag when it already exists

git tag -a v1.0.0 -f -m "a comment"

To create a tag pointing to the same commit as another tag

git tag -a v1.0.0 v1.0.0-rc -m "a comment"

To create a tag pointing to a specific commit

git tag -a v1.0.0 commit -m "a comment"

To checkout working tree at tag (add option -b to create branch at that point in the tree)

git checkout v1.0.0

To view commit log with tags

git log --decorate=full

To push tags to origin (add -f to force update if tag exists on remote)

git push origin --tags

To push tag deletes to origin

git push origin :refs/tags/v1.0.0

For other commands and options use man git or man git-tag.