Skip to content

Instantly share code, notes, and snippets.



Last active Dec 12, 2019
What would you like to do?
git tag

#git tag

Think of a git tag as an alias to a sha1 or to a branch.

The Git Book on tagging says there are two main typs of tags, lightweight and annotated. Lightweight only records commit and tag. Annotated records who, what, when and where. Use annotated, -a.

List all tags:

$ git tag

To tag your current commit:

$ git tag -a <tag_name> -m '<message>'

To tage a previsous commit:

$ git tag -a <tag_name> -m '<message' <sha1>

git push doesn't push the tag names to the repo. To push all tags to the repo:

$ git push origin --tags 

Or individual tag:

$ git push origin <tag_name>

Delete tag localy:

$ git tag -d <tag_name>

Push deleted tag changes to repo:

$ git push origin :refs/tags/<tag_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment