Git: View date and time of tags in a Git repository

Nowadays I’ve got the (good, I think) habit of prefixing all my tags in Git with the date in the ISO 8601 format (e.g. YYYY-MM-DD-name-of-the-tag) so it is easier to find important events that happened in the source code, or to find a commit that matches a particular release when I know the release date (although I tend to trust more on the build server for this one). This is also useful when I just want to navigate through the tags on the server when my repositories are hosted in GitHub or Stash, for example, as they are ordered alphabetically.

Today, however I needed to find the date of an old tag, which I created before I started to prefix them with dates. After a few minutes reading Git’s documentation on the log command, I came up with this very useful Git one-liner:

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

The command above shows all tags in the git repository including the date and the time of creation. Something like this:

$ git log --tags --simplify-by-decoration --pretty="format:%ai %d"
2011-10-15 11:11:13 -0300  (name-of-the-tag-in-the-local-repository)
2011-09-17 10:10:30 -0300  (origin/name-of-the-tag-on-the-remote)
2011-10-20 16:44:10 -0300  (...)
2011-10-16 15:58:07 -0300  (...)

Very handy!

This entry was posted in Version Control and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>