Git Tags - What are they and why you should use them.

Git Tags - What are they and why you should use them.
Photo by Angèle Kamp / Unsplash

Git tags allow developers to create check points in the code base. Something that gets tagged a lot are releases.

Image.png
List of tags for MyWheels

The two types of tags and how to make them

There are two types of tags, lightweight and annotated tags.

A lightweight tag is a pointer to a specific commit with nothing else. It is litterally a checkpoint that you can use to come back to. To make a lightweight tag, use the command git tag {tag name} .

An annotated tag has a lot more to it like the tagger's name, email, and date. It can also have a message a long with it.

Image.png
Annotated tag for MyWheels

To create an annotated tag, use git tag -a {tag name} -m {message} .

How to push a tag?

By default a tag does not get pushed with git push . You will need to run git push origin {tag name} or git push origin --tags . The difference is git push origin {tag name} will only push the one specified tag and git push origin --tag will push all the tags created locally.

Why should you use tags?

Here are a few reasons to use tags

  • Since tags can stay local, then you can create jump points in your code's history that is only visible to you
  • Tags create checkpoints for other developers to know when significant changes occurred
  • Tags will not change even if branches move and change

Maegan Wilson is an indie iOS developer. They love learning about development tools and Swift. Follow them on Instagram to follow my app development process.

Become a member and get my articles, other resources directly to your email, and an ad free experience if you become a paid member.