Show git tags sorted by date

ぃ、小莉子 提交于 2019-12-06 17:16:22

问题


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

git tag only displays alphabetical order.


回答1:


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.




回答2:


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

git tag --sort version:refname



回答3:


Simple to remember:

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

Easier to read result:

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



回答4:


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.




回答5:


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




回答6:


Try this

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


来源:https://stackoverflow.com/questions/21414725/show-git-tags-sorted-by-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!