blob: 1686a54d22a746036b997d6eb8d5b85ca1d79c5d [file] [log] [blame]
Jakub Narebski331b51d2007-05-14 01:25:45 +02001PRETTY FORMATS
2--------------
Chris Riddoch5d1faf82006-11-21 16:49:15 -07003
Jakub Narebski331b51d2007-05-14 01:25:45 +02004If the commit is a merge, and if the pretty-format
5is not 'oneline', 'email' or 'raw', an additional line is
6inserted before the 'Author:' line. This line begins with
7"Merge: " and the sha1s of ancestral commits are printed,
8separated by spaces. Note that the listed commits may not
9necessarily be the list of the *direct* parent commits if you
10have limited your view of history: for example, if you are
11only interested in changes related to a certain directory or
12file.
Chris Riddoch5d1faf82006-11-21 16:49:15 -070013
Jakub Narebski331b51d2007-05-14 01:25:45 +020014Here are some additional details for each format:
15
16* 'oneline'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070017
18 <sha1> <title line>
19+
20This is designed to be as compact as possible.
21
Jakub Narebski331b51d2007-05-14 01:25:45 +020022* 'short'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070023
24 commit <sha1>
25 Author: <author>
26
27 <title line>
28
Jakub Narebski331b51d2007-05-14 01:25:45 +020029* 'medium'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070030
31 commit <sha1>
32 Author: <author>
Markus Heidelbergec9f0ea2008-12-19 13:14:52 +010033 Date: <author date>
Chris Riddoch5d1faf82006-11-21 16:49:15 -070034
35 <title line>
36
37 <full commit message>
38
Jakub Narebski331b51d2007-05-14 01:25:45 +020039* 'full'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070040
41 commit <sha1>
42 Author: <author>
43 Commit: <committer>
44
45 <title line>
46
47 <full commit message>
48
Jakub Narebski331b51d2007-05-14 01:25:45 +020049* 'fuller'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070050
51 commit <sha1>
Markus Heidelbergec9f0ea2008-12-19 13:14:52 +010052 Author: <author>
Nikolaus Schulz2b2da682008-07-05 02:00:13 +020053 AuthorDate: <author date>
Markus Heidelbergec9f0ea2008-12-19 13:14:52 +010054 Commit: <committer>
Nikolaus Schulz2b2da682008-07-05 02:00:13 +020055 CommitDate: <committer date>
Chris Riddoch5d1faf82006-11-21 16:49:15 -070056
57 <title line>
58
59 <full commit message>
60
Jakub Narebski331b51d2007-05-14 01:25:45 +020061* 'email'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070062
63 From <sha1> <date>
64 From: <author>
Nikolaus Schulz2b2da682008-07-05 02:00:13 +020065 Date: <author date>
Chris Riddoch5d1faf82006-11-21 16:49:15 -070066 Subject: [PATCH] <title line>
67
Jakub Narebski331b51d2007-05-14 01:25:45 +020068 <full commit message>
Chris Riddoch5d1faf82006-11-21 16:49:15 -070069
Jakub Narebski331b51d2007-05-14 01:25:45 +020070* 'raw'
Chris Riddoch5d1faf82006-11-21 16:49:15 -070071+
72The 'raw' format shows the entire commit exactly as
73stored in the commit object. Notably, the SHA1s are
74displayed in full, regardless of whether --abbrev or
75--no-abbrev are used, and 'parents' information show the
76true parent commits, without taking grafts nor history
77simplification into account.
Junio C Hamano7cbcf4d2006-12-30 11:59:08 -080078
Jakub Narebski331b51d2007-05-14 01:25:45 +020079* 'format:'
Johannes Schindeline52a5de2007-02-23 01:35:03 +010080+
81The 'format:' format allows you to specify which information
82you want to show. It works a little bit like printf format,
83with the notable exception that you get a newline with '%n'
84instead of '\n'.
Jakub Narebski331b51d2007-05-14 01:25:45 +020085+
86E.g, 'format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"'
Johannes Schindeline52a5de2007-02-23 01:35:03 +010087would show something like this:
Jakub Narebski331b51d2007-05-14 01:25:45 +020088+
89-------
Johannes Schindeline52a5de2007-02-23 01:35:03 +010090The author of fe6e0ee was Junio C Hamano, 23 hours ago
91The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
92
Jakub Narebski331b51d2007-05-14 01:25:45 +020093--------
94+
Johannes Schindeline52a5de2007-02-23 01:35:03 +010095The placeholders are:
96
97- '%H': commit hash
98- '%h': abbreviated commit hash
99- '%T': tree hash
100- '%t': abbreviated tree hash
101- '%P': parent hashes
102- '%p': abbreviated parent hashes
103- '%an': author name
Marius Storm-Olsen7d48e9e2009-02-08 15:34:31 +0100104- '%aN': author name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100105- '%ae': author email
Marius Storm-Olsen7d48e9e2009-02-08 15:34:31 +0100106- '%aE': author email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
Jeff Kingd36f8672008-08-28 20:54:59 -0400107- '%ad': author date (format respects --date= option)
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100108- '%aD': author date, RFC2822 style
109- '%ar': author date, relative
110- '%at': author date, UNIX timestamp
Robin Rosenbergee8f8382007-07-14 01:00:42 +0200111- '%ai': author date, ISO 8601 format
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100112- '%cn': committer name
Marius Storm-Olsen7d48e9e2009-02-08 15:34:31 +0100113- '%cN': committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100114- '%ce': committer email
Marius Storm-Olsen7d48e9e2009-02-08 15:34:31 +0100115- '%cE': committer email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100116- '%cd': committer date
117- '%cD': committer date, RFC2822 style
118- '%cr': committer date, relative
119- '%ct': committer date, UNIX timestamp
Robin Rosenbergee8f8382007-07-14 01:00:42 +0200120- '%ci': committer date, ISO 8601 format
René Scharfe3b3d4432008-09-04 23:40:03 +0200121- '%d': ref names, like the --decorate option of linkgit:git-log[1]
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100122- '%e': encoding
123- '%s': subject
Stephen Boyd46d164b2009-03-22 19:14:01 -0700124- '%f': sanitized subject line, suitable for a filename
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100125- '%b': body
Johannes Schindelin8b208f02009-10-09 12:22:05 +0200126- '%N': commit notes
Thomas Rast8f8f5472009-10-19 17:48:10 +0200127- '%gD': reflog selector, e.g., `refs/stash@\{1\}`
128- '%gd': shortened reflog selector, e.g., `stash@\{1\}`
129- '%gs': reflog subject
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100130- '%Cred': switch color to red
131- '%Cgreen': switch color to green
132- '%Cblue': switch color to blue
133- '%Creset': reset color
Jeff Kingc0029222009-01-17 10:38:46 -0500134- '%C(...)': color specification, as described in color.branch.* config option
Junio C Hamano199c45b2007-04-09 02:34:05 -0700135- '%m': left, right or boundary mark
Johannes Schindeline52a5de2007-02-23 01:35:03 +0100136- '%n': newline
Jeff King0a0416a2010-01-13 12:35:31 -0500137- '%%': a raw '%'
Govind Salinas42c8c742008-03-21 10:05:06 -0500138- '%x00': print a byte from a hex code
René Scharfe3288f202009-11-22 17:15:31 +0100139- '%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of
René Scharfe8a3c63e2009-11-23 23:40:03 +0100140 linkgit:git-shortlog[1].
Jeff Kingfa5b4f32008-06-12 02:14:28 -0400141
Thomas Rast8f8f5472009-10-19 17:48:10 +0200142NOTE: Some placeholders may depend on other options given to the
143revision traversal engine. For example, the `%g*` reflog options will
144insert an empty string unless we are traversing reflog entries (e.g., by
145`git log -g`). The `%d` placeholder will use the "short" decoration
146format if `--decorate` was not already provided on the command line.
147
Junio C Hamano9fa708d2009-10-04 23:43:32 -0700148If you add a `{plus}` (plus sign) after '%' of a placeholder, a line-feed
149is inserted immediately before the expansion if and only if the
150placeholder expands to a non-empty string.
151
152If you add a `-` (minus sign) after '%' of a placeholder, line-feeds that
153immediately precede the expansion are deleted if and only if the
154placeholder expands to an empty string.
155
Jeff Kingfa5b4f32008-06-12 02:14:28 -0400156* 'tformat:'
157+
158The 'tformat:' format works exactly like 'format:', except that it
159provides "terminator" semantics instead of "separator" semantics. In
160other words, each commit has the message terminator character (usually a
161newline) appended, rather than a separator placed between entries.
162This means that the final entry of a single-line format will be properly
163terminated with a new line, just as the "oneline" format does.
164For example:
165+
166---------------------
167$ git log -2 --pretty=format:%h 4da45bef \
168 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1694da45be
1707134973 -- NO NEWLINE
171
172$ git log -2 --pretty=tformat:%h 4da45bef \
173 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1744da45be
1757134973
176---------------------
Nanako Shiraishi36407542009-02-24 18:59:15 +0900177+
178In addition, any unrecognized string that has a `%` in it is interpreted
179as if it has `tformat:` in front of it. For example, these two are
180equivalent:
181+
182---------------------
183$ git log -2 --pretty=tformat:%h 4da45bef
184$ git log -2 --pretty=%h 4da45bef
185---------------------