Is It Bad Practice to Create a Git Tag for Every Successful Deployment?

gittagging

Currently we are using a tag for every build on master which passes CI. This leads to a lot of tags (3-10 per day). The good side is, that those commits are easily human readable, show the version (v.X.Y.ZZZ) which is also shown in the .exe built and deployed of that very commit making it very easy to find the exact commit a specific .exe was generated when bugs are reported.

  • Is this bad practice?
    • If it is, is there any better way?
    • If it is not, is there any way to remove all tags before some specific minor version? Currently when we delete those tags by hand this just leads to someone else repushing them, leading to an endless ping-pong effect.

Best Answer

In practice, because every commit in a git system already has a hash, if all you need is a unique identifier to reproduce a build, or identify a particular state of your branch, you already have that with the commit hash. And obviously your CI system already knows that commit hash. So in this sense, all of those tags are a bit of a waste.

Is it bad practice? I haven't seen anything that would say it's bad, and I can't think of any real problems this will create, but it does seem quite unusual to me. Typically tags are used for releases, and the tags are semver'd. As long as you're semver'ing every tag, it's probably not terrible. Supposing that you actually deploy these builds, maybe it's marginally more useful to identify builds and their associated problems by tag rather than by git commit.

Your usage though seems to fall for me into a very large category we call "personal preference". I doubt the world will burn down if you keep doing it. It wouldn't be my choice, but if your build pipeline isn't broken, I wouldn't recommend "fixing" it to some ethereal state of git perfection.

Related Topic