123

I have seen multiple contradicting definitions on various git flow related websites. Is there an official recommendation or single source of truth?

Branches: release-1.2.3 or release-v1.2.3

Tags: 1.2.3 or v1.2.3

friederbluemle
  • 22,961
  • 11
  • 88
  • 92
  • See also http://stackoverflow.com/questions/2006265/is-there-a-standard-naming-convention-for-git-tags – Raedwald Feb 10 '17 at 12:23

3 Answers3

106

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.

Edit note: Semver no longer specifies usage of the "v" prefix, but does not that it is "a common way to indicate a version number". In fact, Semver explicitly said that "v1.2.3" (for example) "is not a semantic version".

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.


See also: Is there a standard naming convention for git tags?

pepoluan
  • 4,819
  • 3
  • 32
  • 60
TimWolla
  • 28,958
  • 8
  • 59
  • 84
  • 2
    Thanks, that makes sense. I think it is interesting to see that the Git Flow project itself does **not** use the v prefixes: https://github.com/nvie/gitflow For the reasons you and @VonC posted, I still prefer version tags that include the v prefix. – friederbluemle Feb 28 '14 at 17:50
  • 52
    Semver has removed the prefixed *v* in version 2. – schmijos Oct 26 '15 at 10:28
  • 1
    See: https://github.com/mojombo/semver/blob/master/semver.md#user-content-is-v123-a-semantic-version – Leo May 24 '16 at 21:54
  • 10
    @schmijos @LeoTM - The document only states that v1.2.3 is not a semantic version. The question was about Git tags. In fact, the semver repo still uses `v2.0.0` as a tag for version 2: https://github.com/mojombo/semver/releases/tag/v2.0.0 – friederbluemle Oct 25 '16 at 06:20
  • 2
    semver 2.0 http://semver.org doesn't state anything about the tags needed to begin with a "v" prefix! – jankal Nov 13 '16 at 09:07
  • You say Semver does it with the v, but your link to the SemVer definition makes no mention of 'v', and shows many examples without it. – Flimzy May 01 '17 at 16:44
  • 1
    Since there's some debate on what Semver 2.0 says, let me quote it: '“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"' – Jake Stevens-Haas Aug 31 '20 at 03:34
  • 1
    The quoted part by @JakeStevens-Haas means that SemVer no longer "does it that way" as the answer stated, so the answer is claiming something that is no longer true. – pepoluan Dec 31 '20 at 19:28
31

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”".

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 2
    When people are using best practice like _semver_, then they probably use a system like _Git Flow_ or something similar. That would prevent that clash of refs (branch eq tag name). Aside from that, what would hold one back from naming a branch `vX.Y.Z` then? That's not really that much of an argument :) – kaiser Apr 07 '16 at 16:04
  • 3
    semver 2.0 http://semver.org doesn't state anything about the tags needed to begin with a "v" prefix! – jankal Nov 13 '16 at 09:08
  • @jankal I agree. I only mentioned semver for the X.Y.Z policy. – VonC Nov 13 '16 at 09:21
  • One minor argument is that more people will get `v1.2.3` than `b1.2.3` :-) – Ciro Santilli新疆棉花TRUMP BAN BAD Jan 03 '19 at 10:30
3

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”.

Pier
  • 31
  • 3