Tags

Up a Level

A very useful aspect of Git[1] is the ability to mark any commit[2] with additional information. This is called a “tag” and can be used as a form of marker.

1: ../git/
2: ../commits/

Creating a tag is a simple CLI command:

git tag v0.9.0

This attached the tag to the last commit. This is important since the tag won't include any files that have changed but have not be committed. On a forge[3] this will show up on the tags page and commit graph.

3: ../forges/
A screen shot of a commit graph showing the “v0.9.0” tag.

As important note is that Git does not automatically push tags to the remote repository[4]. Instead, you need to push them separately.

4: ../repositories/
git push --tags

Alternatively, you could create a Just[5] target to push both at the same time which would allow `just push` to do everything.

5: ../just/
push:
    git push
    git push --tags

As a note, the tag names must be unique. So you can't have two `v0.0.1` tags.

Internals

Internally, a tag is just a pointer to a specific commit. Once set, it remains pointing to that specific commit but allows you to have a symbolic name, such as `v0.9.0`, instead of the internal identifier, such as `ad301ac018`.

Versioning

While versioning[6] is a more advanced topic, I found the most common use of a tag is identify the project at a certain point as a specific version.

6: ../versioning/

Major Changes

Another use for tags is to identify when you started or stopped working on a major refactor. In this case, you could call `git tag before-chapter-10-rewrite`, do a bunch of commits and changes, and then end with a `git tag after-chapter-10 rewrite`. That way, you don't have to do everything in a single commit (“commit early and often”) but still know you were doing a major change.

This can also be done with a branch[7] but tags are considerably more lightweight and easier than branches, though branches are more flexible.

7: ../branches/

Readers and Editors

Another use of tags is the ability to identify when you gave a copy of the project to a reader. That way, you don't have to remember if you continued to edit the piece while they were reading (I've had readers take 2-3 months to finish).

These days, I use branches exclusively for this but I started with using tags.

git tag sent-to-bob

Footer

Below are various useful links within this site and to related sites (not all have been converted over to Gemini).

Now
Contact
Biography
Bibliography
Support
Fiction
Fedran
Coding
The Moonfires
Categories
Tags
Privacy
Colophon
License
Mailing List