git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Replicating the default "git log" format with a format string.

From
KGKannan Goundan <kannan@cakoose.com>
Date
Nov 12, 2015, 00:55 UTC
Message-ID
<loom.20151112T011419-749@post.gmane.org>
For our workflow, author dates aren't very useful.  I'm looking for a way to
configure Git so that "git log" shows commit dates instead of author dates.
 "--pretty=fuller" gets me almost what I want, but I'd like to avoid the
extra two lines if possible.
I tried achieving this by putting a custom format string in ~/.gitconfig:
[format]
  pretty = "%C(auto,yellow)commit %C(auto)%H\nAuthor: %an <%ae>\nDate:  
%cd\n\n%w(0,4,4)%B"

This works pretty well, but has a few corner cases. When you do "git log --decorate", the default format decorates commits with ref names. I can add "%d" to my format string, but then the ref names show up all the time, even without "--decorate".

The "--walk-reflogs" option presents a similar problem. The %g* placeholders all become empty strings when "--walk-reflogs" isn't present, which is sort of what I want, but it leaves extra blank lines in the output.

Is it possible to exactly replicate the default "git log" format with a format string?

Next: Jeff King
Message 1 of 4 in “Replicating the default "git log" format with a format string.”
  1. Kannan GoundanNov 12, 2015
  2. Jeff KingNov 13, 2015
  3. Jacob KellerNov 13, 2015
  4. Jeff KingNov 13, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.