With --date=local
git log
shows dates in my (user's) timezone:
$ git log --date=local -3 --pretty=tformat:'%cd %h' --abbrev-commit
Thu Dec 18 15:22:11 2014 dc20f74
Thu Dec 18 14:01:26 2014 06c214f
Tue Nov 4 03:48:44 2014 ac33158
The man-page says
-- date [...] Only takes effect for dates shown in human-readable format, such as when using --pretty.
But with ISO format %ci
it does not take effect, as a matter of fact --date=local
and --date=default
product the exact same output:
$ git log --date=local -3 --pretty=tformat:'%ci %h' --abbrev-commit
2014-12-18 23:22:11 +0000 dc20f74
2014-12-18 22:01:26 +0000 06c214f
2014-11-04 17:18:44 +0530 ac33158
$ git log --date=default -3 --pretty=tformat:'%ci %h' --abbrev-commit
2014-12-18 23:22:11 +0000 dc20f74
2014-12-18 22:01:26 +0000 06c214f
2014-11-04 17:18:44 +0530 ac33158
How can I see git log in a less verbose format in my local timezone? Ideally I would like to to see them in '%C%m%dT%H%M%S'
, to use the unix date syntax.
There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.
The command for that would be git log –oneline -n where n represents the number up to which commit you to want to see the logs.
The --graph flag enables you to view your git log as a graph. To make things things interesting, you can combine this command with --oneline option you learned from above. One of the benefit of using this command is that it enables you to get a overview of how commits have merged and how the git history was created.
This format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)' . By default, the date is formatted with --date=short unless another --date option is explicitly specified.
It will be possible with git 2.7 (Q4 2015), which introduces -local
as an instruction.
It means that, in addition of:
--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
you will also have:
--date=(relative-local|default-local|iso-local|iso-strict-local|rfc-local|short-local|raw-local)
You now can ask for any date format using the local timezone.
In your case:
git log --date=iso-local -3 --pretty=tformat:'%cd %h' --abbrev-commit
^^^^^^^^^
|____| that part is new!
See commit 99264e9, commit db7bae2, commit dc6d782, commit f3c1ba5, commit f95cecf, commit 4b1c5e1, commit 8f50d26, commit 78a8441, commit 2df4e29 (03 Sep 2015) by John Keeping (johnkeeping
).
See commit add00ba, commit 547ed71 (03 Sep 2015) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 7b09c45, 05 Oct 2015)
In particular, commit add00ba mentions:
date
: make "local
" orthogonal to date format:Most of our "
--date
" modes are about the format of the date: which items we show and in what order.
But "--date=local
" is a bit of an oddball. It means "show the date in the normal format, but using the local timezone".
The timezone we use is orthogonal to the actual format, and there is no reason we could not have "localized iso8601", etc.This patch adds a "
local
" boolean field to "struct date_mode
", and drops theDATE_LOCAL
element from thedate_mode_type
enum (it's now justDATE_NORMAL
pluslocal=1
).
The new feature is accessible to users by adding "-local
" to any date mode (e.g., "iso-local
"), and we retain "local
" as an alias for "default-local
" for backwards compatibility.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With