You will soon (with Git 1.9.x/2.0, Q2 2014) be able to use git only for getting the right sorted output:
See commit b6de0c6, from commit 9ef176b, authored by Nguyễn Thái Ngọc Duy (pclouds
):
--sort=<type>
Sort in a specific order.
Supported type is:
- "
refname
" (lexicographic order),
- "
version:refname
" or "v:refname
" (tag names are treated as versions).
Prepend "-
" to reverse sort order.
In your case:
git tag -l --sort=version:refname
A few test cases:
git tag foo1.3 &&
git tag foo1.6 &&
git tag foo1.10
Here is what you would get:
# lexical sort
git tag -l --sort=refname "foo*"
foo1.10
foo1.3
foo1.6
# version sort
git tag -l --sort=version:refname "foo*" >actual &&
foo1.3
foo1.6
foo1.10
# reverse version sort
git tag -l --sort=-version:refname "foo*" >actual &&
foo1.10
foo1.6
foo1.3
# reverse lexical sort
git tag -l --sort=-refname "foo*" >actual &&
foo1.6
foo1.3
foo1.10