If you're like me and you use semver for versioning your tags, you probably hate when you do this:
$ git tag -l
0.1.0
0.10.0
0.2.0
0.3.0
0.3.1
0.4.0
0.5.0
0.6.0
0.7.0
0.7.1
0.7.2
0.8.0
0.8.1
0.8.2
0.8.3
0.8.4
0.8.5
0.8.6
0.9.0
because the 0.10.0
tag is hiding way up near the top and you might not even see it.
Here's the solution, create a file on your $PATH
(maybe in your ~/bin
dir) called git-tag-sort
with the contents of the file below, and you should be able to do this:
$ git tag-sort
0.1.0
0.2.0
0.3.0
0.3.1
0.4.0
0.5.0
0.6.0
0.7.0
0.7.1
0.7.2
0.8.0
0.8.1
0.8.2
0.8.3
0.8.4
0.8.5
0.8.6
0.9.0
0.10.0
Have fun!
This is the only valid answer. Everything else breaks down when anything over major+minor+patch is used.
I take that back. Doing that is completely broken in hard to explain ways in some cases… Example:
🤷🏻♂️
The thing that finally worked for me was using Debian-inspired
~
instead of-
for the time of sorting: