Reputation: 1307
My current default git log line runs as follows:
git log --graph --date=relative --pretty=format:'%Cblue%h%Creset %Cgreen(%cr)%Creset -%C(yellow)%d%Creset %s' --abbrev-commit -7
Sometimes, however, I'd prefer an absolute date/time format, rather than relative, so I tried: --date=default
and --date=local
instead of --date=relative
and even left --date=..
out altogether: the result was unchanged. Possibly it has to do with "log.date config variable sets a default value for log command's --date option.", I don't know. Possibly I'd need to restart the terminal (but if that were the case I'd be a tad disappointed...).
In short, I'd like to "toggle" the date, and morever even be able to use both date formats in one instance of git log.
Upvotes: 7
Views: 3176
Reputation: 180867
--pretty=format:'%Cblue%h%Creset %Cgreen(%cr)%Creset -%C(yellow)%d%Creset %s'
%cr
in a format string means relative committer date.
From git help log
;
%cd
: committer date%cD
: committer date, RFC2822 style%cr
: committer date, relative%ct
: committer date, UNIX timestamp%ci
: committer date, ISO 8601 formatChanging the format to for example %ci
will show the date in absolute format.
Upvotes: 12