The difference between tags and branches are that a branch always points to the top of a development line and will change when a new commit is pushed whereas a tag will not change. Thus tags are more useful to "tag" a specific version and the tag will then always stay on that version and usually not be changed.
Tags and branch are completely unrelated, since tags refer to a specific commit, and branch is a moving reference to the last commit of a history. Branches go, tags stay. So when you tag a commit, git doesn't care which commit or branch is checked out, if you provide him the SHA1 of what you want to tag.
However, prefixing a semantic version with a “v” is a common way (in English) to indicate it is a version number. Abbreviating “version” as “v” is often seen with version control. Example: git tag v1.2.3 -m "Release version 1.2. 3", in which case “v1.2.3” is a tag name and the semantic version is “1.2.
Well, basically it is a matter of preference, but I prefer the version with the v
, as Semver does it that way and I try to follow that specification as close as possible to get a sane versioning.
It also makes filtering for those Tags easier, as you can press v
and then the TAB-key for autocompletion: This will list all the tags (and maybe a few branches), whereas there are several digits a tag could start with.
Edit: In 2019, Semver added a section to their FAQ, clarifying that the "v" prefix is "a common way to indicate a version number" (see "Is “v1.2.3” a semantic version?").
See also: Is there a standard naming convention for git tags?
Since v stands for version, tags are generally named vX.Y.Z, with X.Y.Z following Semantic Versioning 2.0.0.
This allows for branches X.Y.Z to co-exist with those tags, without having to deal with error message like "fatal: Ambiguous object name" (as in "Ambiguous Names with GIT?").
Note that the tags for Git itself have recently been "adapted" for a surprising reason: see "Code version change “rules”".
https://semver.org/#is-v123-a-semantic-version
Is “v1.2.3” a semantic version? No, “v1.2.3” is not a semantic version. However, prefixing a semantic version with a “v” is a common way (in English) to indicate it is a version number. Abbreviating “version” as “v” is often seen with version control. Example: git tag v1.2.3 -m "Release version 1.2.3", in which case “v1.2.3” is a tag name and the semantic version is “1.2.3”.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With