The output from git tag
is ordered alphabetically. I would like it to be ordered chronological (the date of the commits they are assigned to, not the date on wh
Try this:
git for-each-ref --sort=taggerdate --format '%(refname) %(taggerdate)' refs/tags
It works perfectly and very fast for me.
Refer to How can I list all tags in my Git repository by the date they were created?
For information, to get it in reverse order, prefix it with "-"
git tag --sort=-taggerdate
Just tested with git 2.8.0:
git tag --sort=committerdate
For a full list of field names you can use, see https://git-scm.com/docs/git-for-each-ref#_field_names
For commit and tag objects, the special
creatordate
andcreator
fields will correspond to the appropriate date or name-email-date tuple from the committer or tagger fields depending on the object type. These are intended for working on a mix of annotated and lightweight tags.Fields that have name-email-date tuple as its value (
author
,committer
, andtagger
) can be suffixed withname
,date
to extract the named component.
git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}'
As Alexander pointed out it should be
git tag --sort=taggerdate
for correct chronological order.
edit: * iff you're interested in the date the tags where pushed, if you're interested in the date of the commits, it should be "commiterdate"
In git 2.3.3 I can just do this to get them sorted by date:
git tag --sort version:refname
PS: For the record, I also answered the same thing on a duplicate question