Tags

There’s one other command I’ve seen used in physics git-managed software projects: tags.

If you’ve played with git reflog, you’ve noticed that git identifies commits with hexadecimal numbers like 9d249f6. That’s fine for git, but they’re not necessarily good for humans. Of course, the comment field is displayed, but as you learned from Figure 138 some comments are better than others.

A tag is a “bookmark” for a particular commit. As shown in the example, mostly they’re used to indicate version release numbers.

As an example, here’s the result of my using

git tag

in a project that I managed:

v0.1
v0.5
v1.0
v1.1-GramsSky
v1.2-GramsDetSim
v1.3-GramsReadoutSim-GramsElecSim
v1.4-Options-Geometry
v1.5
v1.5.1
v1.6
v2.0
v2.1
v2.2
v2.4

As you can see, for some of the tags I included the names of significant packages that I added at the time I created the tag. For my most recent tags, I didn’t bother.

The reason why I stopped using descriptive tag names and just stuck with version numbers is that I learned about the following command:

git tag -n1

It lists each tag along with the first line of whatever comment I made when creating it e.g.,

v0.1            Open a github repository for GramsG4 (later GramsSim)
v0.5            Semi-arbitrary: The first version of GramsG4 to be used by someone other than William Seligman.
v1.0            The package is now GramsSim
v1.1-GramsSky   Milestone: GramsSky now ready for real use.
v1.2-GramsDetSim GramsDetSim ready for serious use.
v1.3-GramsReadoutSim-GramsElecSim GramsReadoutSim and GramsElecSim added to GramsSim
v1.4-Options-Geometry GramsSim output files now contain a history of their Options and the
v1.5            First pass at pGRAMS geometry
v1.5.1          Added upper and lower limits to Options processing.
v1.6            The last version that uses the less-convenient n-tuple format for the programs' output files.
v2.0            BREAKING CHANGE: Switch to tree-based file format
v2.1            Full Mac OS X compatibility
v2.2            Fix GramsSky->GramsG4 energy, improve organization
v2.4            Added simd

To create a tag with the name v2.5 and the comment This is a new tag:

git tag -a v2.5 -m "This is a new tag"

By default, tags are only applied within your local directory. If you want the tag recorded to a remote repository, you have to explicitly use git push; e.g.,

git push origin v2.5

If someone has added new tags to the remote repository, you can download them in the same way you can download remote branches:

git fetch

I’ve never had the occasion to look at a project’s state as of a particular tag, but I know the command:

git checkout v2.5

For other fun things to do with tags, I’ll once again refer you to the Git book.

xkcd api

Figure 140: https://xkcd.com/1481/ by Randall Munroe