I have a project that is using git and have tagged all the releases with a tag.
$ git tag
v1.0.0
v1.0.1
v1.0.2
v1.0.3
v1.1.0
My goal is to list the releases and release dates in a web interface (tag/commit date = release date). Currently we list all the releases by using git tag
.
How can I get the time and date for when the tag was made (or the commit it points to)?
This always worked for me:
Consult the "PRETTY FORMATS" section of the git-log manpage for details of the format string if you want a different date formatting.
Use the
--format
argument togit log
:one can use
gawk
(notawk
) to convert date in the "tagger" line to something human-readable:if one does not like
gawk
thendate
can be used to convert unix time:and example (
dnsmasq
git repo):Note that both of the above solutions get you the commit date, which can be wildly different than when that commit was tagged for release. To get the date of the tag itself, you've got to find the tag itself with
rev-parse
, read it withcat-file
, and then parse it. A little pipeline:git rev-parse v1.0.0 | xargs git cat-file -p | egrep '^tagger' | cut -f2 -d '>'
There is no simple option in git tag command to do this. I found most convenient to run
to list all commits including tags if there are some. For listing only commits that are tagged use
For details use
One more option:
See https://git-scm.com/docs/git-for-each-ref#_field_names for format options
%(creatordate)
gives the date of the commit pointed to, to see the date the tag was created on use%(taggerdate)
You can incorporate the shell directly: