Skip to content

Instantly share code, notes, and snippets.

@AvnerCohen
Last active July 21, 2018 18:39
Show Gist options
  • Save AvnerCohen/b433936162bb2afe4bc2 to your computer and use it in GitHub Desktop.
Save AvnerCohen/b433936162bb2afe4bc2 to your computer and use it in GitHub Desktop.
A sorted list of git tags - A simple way to create a git alias to a sorted list of tags, sorted by their creation date, and not alphanumerically.

Extract a sorted by creation list list of git repository tags:

The git command line:

git for-each-ref --format='%(*committerdate:raw)%(committerdate:raw) %(refname) %(*objectname) %(objectname)' refs/tags | sort -n | cut -d'/' -f 3 | cut -d' ' -f 1

Create a new git alias for it (stags - Sorted tags):

vi ~/.gitconfig
# place the new alias in the alias section:
[alias]
    stags = !git for-each-ref --format='%(*committerdate:raw)%(committerdate:raw) %(refname) %(*objectname) %(objectname)' refs/tags | sort -n | cut -d'/' -f 3 | cut -d' ' -f 1

enjoy with:

git stags
@kuri65536
Copy link

git tag -l --sort=creatordate

@AvnerCohen
Copy link
Author

True. This was not an available feature in git, back in 2015.

@kuri65536
Copy link

Thank you comment.

I googled for this feature and got your gist.
I hope this gist and comments to be someone help. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment