Show git tags sorted by date

How to list git tags in chronological order? (recent tags first)

git tag only displays alphabetical order.


The correct answer is:

git tag --sort=-taggerdate

taggerdate is the appropriate field. According to the git tag man page:

Prefix - to sort in descending order of the value.

git tag uses the same sorting keys as git-for-each-ref, which is where the sorting keys are documented.

In git 2.3.3 I can just do this to get them sorted by date:

git tag --sort version:refname

Simple to remember:

git log --tags --decorate --simplify-by-decoration

Easier to read result:

git log --tags --simplify-by-decoration --pretty="format:%d - %cr"

There is a nice one-liner I found that will shows date tag message, tag author and does a good job with column arrangements.

git for-each-ref --sort=taggerdate --format '%(tag)_,,,_%(taggerdate:raw)_,,,_%(taggername)_,,,_%(subject)' refs/tags \
 | awk 'BEGIN { FS = "_,,,_"  } ; { t=strftime("%Y-%m-%d  %H:%M",$2); printf "%-20s %-18s %-25s %s\n", t, $1, $4, $3  }'

Output will look like this:

2015-08-03  10:56     v1.51              Release v1.51             FirstName LastName
2015-08-10  16:12     v1.52              Release v1.52             Jane Doe

Credit to this site

Supported types when it comes to sorting with git tag are:

  • refname - sorts in a lexicographic order
  • version:refname or v:refname - this sorts based on versions

The solution to your problem would look like: git tag -l --sort version:refname

There are many more useful commands related to git tagging, be sure to check this article out for more details.

Try this

 git log --tags --decorate --simplify-by-decoration | grep ^commit|grep tag|sed -e 's/^.*: //' -e 's/)$//'

Need Your Help

Java: where do static fields live within the memory?

java class static

If we store objects in static fields of an object, how does the JVM allocate the memory for it? Does it live within "implicit"(not sure if I am using the right word) class object? How are static fi...