Question

I currently use:

git log --pretty='format:%ad %Cgreen%h%Cred%d %Creset%s' --date=local

which produces:

Tue Apr 2 16:02:24 2013 b8b3975 Debug info for hidHandle.isClosed added.
Mon Apr 1 15:31:46 2013 6b9b1ca Fixed mouse-button-up event images.
Mon Apr 1 13:23:26 2013 907e8c6 Improved code-behind formatting.
Thu Mar 28 17:14:59 2013 d2edade Remember colors on redraw.
Thu Mar 28 16:49:51 2013 7491a07 Seven colors in a row.

I desire for this:

Tue Apr 02 16:02:24 2013 b8b3975 Debug info for hidHandle.isClosed added.
Mon Apr 01 15:31:46 2013 6b9b1ca Fixed mouse-button-up event images.
Mon Apr 01 13:23:26 2013 907e8c6 Improved code-behind formatting.
Thu Mar 28 17:14:59 2013 d2edade Remember colors on redraw.
Thu Mar 28 16:49:51 2013 7491a07 Seven colors in a row.

Results using --date=relative, --date=iso, --date=rfc and --date=default were not satisfactory.

Am I missing any other option? I am using git version 1.8.1.msysgit.1 on Windows 7 64-bit.

Was it helpful?

Solution

Had a quick look at the sourcecode and what you desire is not possible. You only get that one format if you want timezone-adjusted times. If it’s important to you, you could pass the output through sed:

git log --pretty='format:%ad %Cgreen%h%Cred%d %Creset%s' --date=local | sed 's/^\(.\{7\}\) \([0-9]\) /\1 0\2 /'

If you want to set this up as an alias mylog, run this command:

git config --global alias.mylog '!'"git log --pretty='format:%ad %Cgreen%h%Cred%d %Creset%s' --date=local | sed 's/^\(.\{7\}\) \([0-9]\) /\1 0\2 /'"

Or add this to your ~/.gitconfig

[alias]
        mylog = !git log --pretty='format:%ad %Cgreen%h%Cred%d %Creset%s' --date=local | sed 's/^\\(.\\{7\\}\\) \\([0-9]\\) /\\1 0\\2 /'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top