views:

227

answers:

1

I really like the short git log format where I can see author, date and change description like this:

git log --pretty=format:"%h%x09%an%x09%ad%x09%s"

Which 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

(from stackoverflow question "link text")

Now, the question is, how do I save this as a new format on my machine so I only have to write something like, for instance:

git log --format=jespers_favourite
+5  A: 

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"
VonC
I accepted this, but actually thre is an error. it should not say "= git log" but just "= log" like this:[alias] compactlog = log --pretty=format:"%h%x09%an%x09%ad%x09%s"
Jesper Rønn-Jensen
@Jesper: good point: I fixed the answer.
VonC
Cool thanks! much better for other viewers to learn from:)
Jesper Rønn-Jensen