List only the most recent SemVer version number per major.minor branch
Here’s a handy snippet to show only v1.3
, v2.1
out of a range like v1.0
, v1.1
, v1.2
, v1.3
, v2.0
, v2.1
:
git tag -l "v*.*.*" --sort=-v:refname | awk -F. '!seen[$1,$2]++'
(Input does not have to come from git
, it can be any newline-delimited list of version numbers)
Example
$ git tag -l "v*.*.*" --sort=-v:refname
v0.10.1
v0.10.0
v0.9.0
v0.8.1
v0.8.0
v0.7.0
v0.6.1
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.7
v0.1.6
v0.1.5
v0.1.4
v0.1.3
v0.1.2
v0.1.1
$ git tag -l "v*.*.*" --sort=-v:refname | awk -F. '!seen[$1,$2]++'
v0.10.1
v0.9.0
v0.8.1
v0.7.0
v0.6.1
v0.5.2
v0.4.0
v0.3.0
v0.2.1
v0.1.7