You should take a look at this post. It gives a very nice exemple of a customize git log. And also an oneliner to define it with a Git alias.
To try it, you can type:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
To define it in an alias:
git config --global alias.lg "git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
To use it :
git lg
To check your configuration:
git config alias.lg
To remove it:
git config --unset alias.lg
date=short
If you want to go further in the configuration, you should look at the Git pretty-formats documentation (placeholders section).
For the date you were talking about, you could change the %cr by %ad because this format respects the --date=option. So you could use --date=short as you want.
Tig
To finish there is a very powerful tool you could use if you are a command line lover like me: Tig
Answer from Nicolas Dupouy on Stack OverflowVideos
You should take a look at this post. It gives a very nice exemple of a customize git log. And also an oneliner to define it with a Git alias.
To try it, you can type:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
To define it in an alias:
git config --global alias.lg "git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
To use it :
git lg
To check your configuration:
git config alias.lg
To remove it:
git config --unset alias.lg
date=short
If you want to go further in the configuration, you should look at the Git pretty-formats documentation (placeholders section).
For the date you were talking about, you could change the %cr by %ad because this format respects the --date=option. So you could use --date=short as you want.
Tig
To finish there is a very powerful tool you could use if you are a command line lover like me: Tig
This will become possible with the --pretty=format:%S token supported in the upcoming Git 2.21.0.
In newer versions of Git (confirmed with v1.7.8) it is possible to set named pretty-print log formats using git config pretty.named_format. These can be set at a machine-wide, user or file level with the <file-option> argument.
To create a log format called jespers_favourite or the whole machine use --system
git config --system pretty.jespers_favourite "%h%x09%an%x09%ad%x09%s"
For single user use '--global'
git config --global pretty.jespers_favourite "%h%x09%an%x09%ad%x09%s"
Leaving the <file-option> argument blank will default to setting the config file of the current repository, .git/config unless defined otherwise.
Considering the git log manual page mentions:
--pretty[=<format>]
--format[=<format>]
Pretty-print the contents of the commit logs in a given format, where can be one of oneline, short, medium, full, fuller, email, raw and format:. When omitted, the format defaults to medium.
the <format> can only have predefined values.
That only leaves you the possibility to define an alias as a shortcut for that command.
[alias]
jespers_favourite = log --pretty=format:"%h%x09%an%x09%ad%x09%s"
or
[alias]
compactlog = log --pretty=format:"%h%x09%an%x09%ad%x09%s"
Rokit adds in the comments:
Escaping the quotes worked until I tried adding custom colors.
For that, I also had to add an additional set of regular quotes around the escaped ones, e.g.log --pretty=format:"\"%C(#9be3bc) %s\""
git show --format="YOUR_FORMAT" -s
-s suppresses the diffs from showing.
YOUR_FORMAT is documented at:
man git-log
section PRETTY FORMATS
For example, to get just commit SHAs and author email for a few SHAs:
git show --format="%H %ae" -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f
gives output for format:
62f6870e4e0b384c4bd2d514116247e81b241251 [email protected]
96ee0246ce52012644dd18cf360e64c49016fb7f [email protected]
To add newlines and more fields to the format, you could do:
git show --format=$'%H\n%ae\n%an\n' -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f
Which gives output for form:
62f6870e4e0b384c4bd2d514116247e81b241251
[email protected]
Ciro Santilli
96ee0246ce52012644dd18cf360e64c49016fb7f
[email protected]
Ciro Santilli
Im using this script (as alias):
https://github.com/vheon/home/blob/master/.githelpers
git alias:
l = "!bash -c 'source ~/.githelpers && pretty_git_log'"
the output is this:

You will have to use your own git log --pretty=format options.
In the --pretty you can set colors and choose any content you would like to display
format:<string>The format: format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with %n instead of \n.
E.g, format:
The author of %h was %an, %ar%nThe title was >>%s<<%nwould show something like this:
The author of fe6e0ee was Junio C Hamano, 23 hours ago
The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
The placeholders are:
%C(…):color specification, as described in color.branch.* config option; adding auto, at the beginning will emit color only when colors are enabled for log output (by color.diff, color.ui, or --color, and respecting the auto settings of the former if we are going to a terminal). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.
%C(…):color specification, as described in color.branch.* config option; adding auto, at the beginning will emit color only when colors are enabled for log output (by color.diff, color.ui, or --color, and respecting the auto settings of the former if we are going to a terminal). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.
%Cblue:switch color to blue
%Cgreen:switch color to green
%Cred:switch color to red
%Creset:reset color
%D:ref names without the " (", ")" wrapping.
%G?:show "G" for a Good signature, "B" for a Bad signature, "U" for a good, untrusted signature and "N" for no signature
%GG:raw verification message from GPG for a signed commit
%GK:show the key used to sign a signed commit
%GS:show the name of the signer for a signed commit
%H:commit hash
%N:commit notes
%P:parent hashes
%T:tree hash
%aD:author date, RFC2822 style
%aE:author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%aI:author date, strict ISO 8601 format
%aN:author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%ad:author date (format respects --date= option)
%ae:author email
%ai:author date, ISO 8601-like format
%an:author name
%ar:author date, relative
%at:author date, UNIX timestamp
%b:body
%cD:committer date, RFC2822 style
%cE:committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cI:committer date, strict ISO 8601 format
%cN:committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cd:committer date (format respects --date= option)
%ce:committer email
%ci:committer date, ISO 8601-like format
%cn:committer name
%cr:committer date, relative
%ct:committer date, UNIX timestamp
%d:ref names, like the --decorate option of git-log(1)
%e:encoding
%f:sanitized subject line, suitable for a filename
%gD:reflog selector, e.g., refs/stash@{1}
%gE:reflog identity email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gN:reflog identity name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gd:shortened reflog selector, e.g., stash@{1}
%ge:reflog identity email
%gn:reflog identity name
%gs:reflog subject
%h:abbreviated commit hash
%m:left, right or boundary mark
%n:newline
%p:abbreviated parent hashes
%s:subject
%t:abbreviated tree hash
%w([<w>[,<i1>[,<i2>]]]):switch line wrapping, like the -w option of git-shortlog(1).
%x00:print a byte from a hex code
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
does the job. This outputs:
fbc3503 mads Thu Dec 4 07:43:27 2008 +0000 show mobile if phone is null...
ec36490 jesper Wed Nov 26 05:41:37 2008 +0000 Cleanup after [942]: Using timezon
ae62afd tobias Tue Nov 25 21:42:55 2008 +0000 Fixed #67 by adding time zone supp
164be7e mads Tue Nov 25 19:56:43 2008 +0000 fixed tests, and a 'unending appoi
93f1526 jesper Tue Nov 25 09:45:56 2008 +0000 adding time.ZONE.now as time zone
2f0f8c1 tobias Tue Nov 25 03:07:02 2008 +0000 Timezone configured in environment
a33c1dc jesper Tue Nov 25 01:26:18 2008 +0000 updated to most recent will_pagina
It was inspired by Stack Overflow question: "Git log output like 'svn ls -v'". I found out that I could add the exact parameters I needed.
To shorten the date (not showing the time), use --date=short.
In case you were curious what the different options were:
%h= abbreviated commit hash%x09= tab (character for code 9)%an= author name%ad= author date (format respects --date= option)%s= subject
It is from git-log(1) Manual Page (PRETTY FORMATS section) by the comment of Vivek.
I use these two .gitconfig file settings:
[log]
date = relative
[format]
pretty = format:%h %Cblue%ad%Creset %ae %Cgreen%s%Creset
%ad is the author date, which can be overridden by --date or the option specified in the [log] stanza in .gitconfig.
I like the relative date, because it gives an immediate feeling of when stuff was committed.
The output looks like this:
6c3e1a2 2 hours ago [email protected] lsof is a dependency now.
0754f18 11 hours ago [email protected] Properly unmount, so detaching works.
336a3ac 13 hours ago [email protected] Show ami registration command if auto register fails
be2ad45 17 hours ago [email protected] Fixes #6. Sao Paolo region is included as well.
5aed68e 17 hours ago [email protected] Shorten while loops
This is all of course in color, so it is easy to distinguish the various parts of a log line.
Also it is the default when typing git log because of the [format] section.
Since Git now supports padding, I have a nice amendment to the version above:
pretty = format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s
This right aligns the relative dates and left aligns committer names, meaning you get a column-like look that is easy on the eyes.
Screenshot

Since GPG commit signing is becoming a thing, here is a version that includes signature verification (in the screenshot it's the magenta letter right after the commit). A short explanation of the flag:
%G?: show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity and "N" for no signature
Other changes include:
- colors are now removed if the output is to something other than the tty (which is useful for grepping, etc.)
git log -gnow contains the reflog selector.- Save two parentheses on refnames and put them at the end (to preserve column alignment)
- Truncate relative dates if they are too long (e.g.,
3 years, 4..) - Truncate committer names (it might be a little short for some people, but just change the
%<(7,trunc)or check out the Git .mailmap feature to shorten committer names)
Here's the configuration:
pretty = format:%C(auto,yellow)%h%C(auto,magenta)% G? %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(7,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD% D
All in all column alignment is now preserved a lot better at the expense of some (hopefully) useless characters.
I'd love to make the message color depend on whether a commit is signed, but it doesn't seem like that is possible at the moment.
Screenshot
