6

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.

nutty about natty
  • 1,267
  • 2
  • 10
  • 17
  • As a side note, you probably want to see author information in your log. They are usually the same but not always. More info here http://stackoverflow.com/q/18750808/761771 – Nate Jul 22 '14 at 18:05

1 Answers1

12

--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 format

Changing the format to for example %ci will show the date in absolute format.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • 1
    Thanks! and regarding my second question, this (based on your comments) works and answers it: `git log --pretty=format:'%Cblue%h%Creset %Cgreen(%cr)%Creset %Cblue(%cd)%Creset -%C(yellow)%d%Creset %s'` – nutty about natty Apr 29 '13 at 19:30