The Farrelly logo

Git tags: standard, and somewhat unnecessary

Git tags are a well-known, well loved member of the release process. A human-readable way to know what a codebase was like at a point in time, normally used at an important milestone, or to denote stability. But do you need to use them?

During a release, one of the tasks you’ll need to do is bump the current version. Generally by incrementing the patch number (assuming semantic versioning). Then you’ll create a git tag, as shown in the git docs:

// lightweight
git tag v1.2
// annotated
git tag -a v1.2 -m 'version 1.2'

But why are we creating a tag?

Git tags provide a human readable way to view the codebase at a particular point in time. The alternative option is to use a commit hash instead.

Say we’ve released our second minor update, ‘version 1.2’, but we’ve found a nasty bug which has broken everything. We need to revert to the previous version, ‘version 1.1’. While we’re working on fixing the issues, we checkout from the previous version and release that stable version. When we do that, we have two choices on how we find that previous stable release.

Knowing that ‘version 1.1’ was stable, we can either checkout from that tag i.e. git checkout v1.2, or use the commit hash i.e git checkout d0f9b4….

What’s the difference between using the commit hash, or the tag?

Just the data you entered after ‘checkout’. Remember a git tag is just a human readable way to read a commit hash, they’re essentially the same thing.

So why would you use a tag instead of the commit hash?

It’s easier to read. That’s it. It doesn’t provide any hidden benefit, it’s just a more readable way to find a specific point in time of your codebase.

So do you need tags in your release process?

Need? No. You don’t need it, you could do without it. Git tags do provide a small benefit over not using them, so they’re sort of a ‘why not’. It’s a similar argument as to why you should use a code formatter, there is more benefit to using one than not (there are definitely more reasons why you should use a code formatter).

So are tags unnecessary?

If you’re striving to be lean, and have the barebones of what you need to get going. It can be unnecessary. It’s a nice-to-have, but not a need. So you could say they are unnecessary.

Conclusion

So should you use git tags? Personally I would say it’s better to have it than not. But if you didn’t I don’t have a compelling argument to convince you otherwise.

What do you think?

Is there a compelling argument to use git tags?

Would you consider them unnecessary?

Do you use git tags?