Git tag


Git tags are extremely useful when marking a milestone or release. Here’s what you can do with it:

Create

To create a lightweight tag from the current commit:

git tag <tagname>

Example:

git tag v1.0.0

To create an annotated tag from the current commit:

git tag -a <tagname> -m <message>

Example:

git tag -a v1.0.0 -m "First release"

The difference between lightweight tags and annotated tags is lightweight tags use the existing commit whereas annotated tags create a new commit checksum.

To tag a different commit:

git tag <tagname> <hash>

Example:

git tag v0.1.0 a1b2c3d

View

To list all tags:

git tag

To show the contents of a tag:

git show <tagname>

Example:

git show v1.0.0

Push

To push a tag to the remote repository:

git push <remote> <tagname>

Example:

git push origin v1.0.0

To push all tags to the remote repository:

git push <remote> --tags

Example:

git push origin --tags

Delete

To remove a tag from the local repository:

git tag -d <tagname>

Example:

git tag -d v1.0.0

To remove a tag from the remote repository:

git push <remote> :refs/tags/<tagname>

Example:

git push origin :refs/tags/v1.0.0


Please support this site and join our Discord!