If your tags are sortable using the linux sort
command, use this:
git tag | sort -n | tail -1
eg. if git tag
returns:
v1.0.1
v1.0.2
v1.0.5
v1.0.4
git tag | sort -n | tail -1
will output:
v1.0.5
git tag | sort -n | tail -2 | head -1
will output:
v1.0.4
(because you asked for the second most recent tag)
to checkout the tag, first clone the repo, then type:
git checkout v1.0.4
..or whatever tag you need.