Say below command list all git tags, how to modify it to get the largest tag?
git tag
Current output is:
V1.0.0
V1.0.1
V1.0.2
...
V1.0.23
I expect the output is V1.0.23 for this example
CodePudding user response:
Have Git sort them for you, by version, descending, and pick just the first one:
git tag --list --sort='-version:refname' | head -n1
Or pipe the tags to a sort that knows version sort (such as GNU sort):
git tag | sort -rV | head -n1