Consider this list of version numbers:
0.3.0
0.3.1
...
0.3.8
0.3.9
0.3.10
0.3.11
git tag
would print them in the following order:
0.3.0
0.3.1
0.3.10
0.3.11
0.3.2
...
I there any way to make git tag
print them in 'numeric' order as opposed to alphabetical order? Or a workaround - perhaps a program I can pipe the output through to order them how I want?
Easier solution:
Breakdown of the
sort
options being used here: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
):In your case:
A few test cases:
Here is what you would get:
Breakdown of the
sort
options being used here:-n
- sort using numerical string order (thus10
comes after1
)-t.
- use periods as field separators-k1,1
define a sort key on the first field (and only the first field)-k2,2
define a sort key on the second field (and only the second field)-k3,3
define a sort key on the third field (and only the third field)