# git tag listing order

3 messages from 2009-11-24 to 2009-11-24. Participants: Peter van der Does, Jeff King.
Thread: https://gitlist.dev/t/21739

## Peter van der Does, 2009-11-24 15:56

Subject: git tag listing order
Message-ID: <20091124105609.0980e796@montecarlo.grandprix.int>
URL: https://gitlist.dev/e/20091124105609.0980e796%40montecarlo.grandprix.int

```
I'm using git 1.6.5.3 on Ubuntu and was wondering if there is a way to
list tags in order of when they were added to the tree, instead of
alphabetical?


-- 
Peter van der Does

GPG key: E77E8E98
Twitter: @petervanderdoes
git Ubuntu Packages:
http://blog.avirtualhome.com/git-packages-for-ubuntu/

```

## Jeff King, 2009-11-24 19:00

Subject: Re: git tag listing order
Message-ID: <20091124185947.GA24409@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20091124185947.GA24409%40coredump.intra.peff.net
In-Reply-To: <20091124105609.0980e796@montecarlo.grandprix.int>

```
On Tue, Nov 24, 2009 at 10:56:09AM -0500, Peter van der Does wrote:

> I'm using git 1.6.5.3 on Ubuntu and was wondering if there is a way to
> list tags in order of when they were added to the tree, instead of
> alphabetical?

You can use for-each-ref with its sort option:

  git for-each-ref --sort=taggerdate --format='%(refname:short)' refs/tags

Though note that unannotated tags will have no taggerdate, and will all
sort to the front of the list. To exclude them, I think you'd have to
use a special format to grep and sort yourself. Something like:

  git for-each-ref \
    --format='%(taggerdate:iso8601) %(refname:short)' refs/tags |
    grep -v '^ ' |
    sort |
    cut -d' ' -f4-

-Peff

```

## Peter van der Does, 2009-11-24 19:24

Subject: Re: git tag listing order
Message-ID: <20091124142428.514564d6@montecarlo.grandprix.int>
URL: https://gitlist.dev/e/20091124142428.514564d6%40montecarlo.grandprix.int
In-Reply-To: <20091124185947.GA24409@coredump.intra.peff.net>

```
On Tue, 24 Nov 2009 14:00:23 -0500
Jeff King <peff@peff.net> wrote:

> On Tue, Nov 24, 2009 at 10:56:09AM -0500, Peter van der Does wrote:
> 
> > I'm using git 1.6.5.3 on Ubuntu and was wondering if there is a way
> > to list tags in order of when they were added to the tree, instead
> > of alphabetical?
> 
> You can use for-each-ref with its sort option:
> 
>   git for-each-ref --sort=taggerdate --format='%(refname:short)'
> refs/tags
> 
> Though note that unannotated tags will have no taggerdate, and will
> all sort to the front of the list. To exclude them, I think you'd
> have to use a special format to grep and sort yourself. Something
> like:
> 
>   git for-each-ref \
>     --format='%(taggerdate:iso8601) %(refname:short)' refs/tags |
>     grep -v '^ ' |
>     sort |
>     cut -d' ' -f4-
> 
> -Peff
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks for the info, just what I was looking for.

-- 
Peter van der Does

GPG key: E77E8E98
Twitter: @petervanderdoes
git Ubuntu Packages:
http://blog.avirtualhome.com/git-packages-for-ubuntu/

```
