Git: creating and deleting a tag

Updated . Posted . Visible to the public.

Git has two kind of tags:

  • annotated
  • lightweight

Annotated tags are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG)

The following command will create a (lightweight) tag:

git tag v0.1

An annotated tag is created by:

git tag -a v0.1 -m "a special tag message"

A normal git push will not push the tag. So in order to publish your (local) tags, you have to

git push --tags

Check if a tag is annotated

You can use git show to see the annotation message of an annotated tag:

$ git show v1.4
tag v1.4
Tagger: Some User <some@user.com>
Date:   Mon Oct 23 20:19:12 2017 +0200

my version 1.4

commit d24e7102ea99867e254c374c0d9bba5faf793b25
Author: Another User <another@user.com>
Date:   Sun Oct 22 12:52:11 2017 +0200

    changed the version number

Lightweigt tags obviously won't have an annotation message.


Remove a tag (local and remote)

To remove a tag on your work machine, use

git tag -d v0.1

To also delete it from remote, you will have to do

git push origin :refs/tags/v0.1

or

git push origin -d v0.1
Profile picture of Daniel Straßner
Daniel Straßner
Last edit
Daniel Straßner
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2017-10-23 09:49)