blob: bb38215b3bd1bfe9ed72b5f3a38c2eeefebafa5c [file] [log] [blame]
Junio C Hamanob33fb4f2006-04-18 21:30:511<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamanob33fb4f2006-04-18 21:30:517<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamanob33fb4f2006-04-18 21:30:5126
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamanob33fb4f2006-04-18 21:30:5148 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamanob33fb4f2006-04-18 21:30:5151 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamanob33fb4f2006-04-18 21:30:5159
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamanob33fb4f2006-04-18 21:30:5184}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamanob33fb4f2006-04-18 21:30:51155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamanob33fb4f2006-04-18 21:30:51166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamanob33fb4f2006-04-18 21:30:51171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamanob33fb4f2006-04-18 21:30:51215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamanob33fb4f2006-04-18 21:30:51220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamanob33fb4f2006-04-18 21:30:51236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamanob33fb4f2006-04-18 21:30:51275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamanob33fb4f2006-04-18 21:30:51306</style>
307<title>git-blame(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-blame(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-blame -
Junio C Hamano6b2cee12006-08-26 08:43:31317 Show what revision and author last modified each line of a file
Junio C Hamanob33fb4f2006-04-18 21:30:51318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoe1aa7472006-11-09 07:37:50323<div class="verseblock">
Junio C Hamanofce7c7e2008-07-02 03:06:38324<div class="content"><em>git blame</em> [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
Junio C Hamano0e3cb532007-04-17 08:28:11325 [-S &lt;revs-file&gt;] [-M] [-C] [-C] [--since=&lt;date&gt;]
Junio C Hamanoa6455f62009-02-20 08:33:08326 [&lt;rev&gt; | --contents &lt;file&gt; | --reverse &lt;rev&gt;] [--] &lt;file&gt;</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51327</div>
Junio C Hamanoba4b9282008-07-06 05:20:31328<h2 id="_description">DESCRIPTION</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51329<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31330<div class="para"><p>Annotates each line in the given file with information from the revision which
331last modified the line. Optionally, start annotating from the given revision.</p></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41332<div class="para"><p>The command can also limit the range of lines annotated.</p></div>
333<div class="para"><p>The report does not tell you anything about lines which have been deleted or
Junio C Hamanoba4b9282008-07-06 05:20:31334replaced; you need to use a tool such as <em>git-diff</em> or the "pickaxe"
335interface briefly mentioned in the following paragraph.</p></div>
336<div class="para"><p>Apart from supporting file annotation, git also supports searching the
Junio C Hamanof9771f62007-01-17 17:42:30337development history for when a code snippet occurred in a change. This makes it
Junio C Hamano6b2cee12006-08-26 08:43:31338possible to track when a code snippet was added to a file, moved or copied
339between files, and eventually deleted or replaced. It works by searching for
Junio C Hamanoba4b9282008-07-06 05:20:31340a text string in the diff. A small example:</p></div>
Junio C Hamano6b2cee12006-08-26 08:43:31341<div class="listingblock">
342<div class="content">
343<pre><tt>$ git log --pretty=oneline -S'blame_usage'
3445040f17eba15504bad66b14a645bddd9b015ebb7 blame -S &lt;ancestry-file&gt;
345ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</tt></pre>
346</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51347</div>
Junio C Hamanoba4b9282008-07-06 05:20:31348<h2 id="_options">OPTIONS</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51349<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31350<div class="vlist"><dl>
Junio C Hamanob33fb4f2006-04-18 21:30:51351<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11352-b
Junio C Hamanob33fb4f2006-04-18 21:30:51353</dt>
354<dd>
355<p>
Junio C Hamano0e3cb532007-04-17 08:28:11356 Show blank SHA-1 for boundary commits. This can also
357 be controlled via the <tt>blame.blankboundary</tt> config option.
358</p>
359</dd>
360<dt>
361--root
362</dt>
363<dd>
364<p>
365 Do not treat root commits as boundaries. This can also be
366 controlled via the <tt>blame.showroot</tt> config option.
367</p>
368</dd>
369<dt>
370--show-stats
371</dt>
372<dd>
373<p>
374 Include additional statistics at the end of blame output.
Junio C Hamanob33fb4f2006-04-18 21:30:51375</p>
376</dd>
377<dt>
Junio C Hamano9882a522007-04-27 08:22:22378-L &lt;start&gt;,&lt;end&gt;
Junio C Hamanoe1aa7472006-11-09 07:37:50379</dt>
380<dd>
381<p>
Junio C Hamano9882a522007-04-27 08:22:22382 Annotate only the given line range. &lt;start&gt; and &lt;end&gt; can take
383 one of these forms:
Junio C Hamanoe1aa7472006-11-09 07:37:50384</p>
Junio C Hamanoba4b9282008-07-06 05:20:31385<div class="ilist"><ul>
Junio C Hamano9882a522007-04-27 08:22:22386<li>
387<p>
388number
389</p>
Junio C Hamanoba4b9282008-07-06 05:20:31390<div class="para"><p>If &lt;start&gt; or &lt;end&gt; is a number, it specifies an
391absolute line number (lines count from 1).</p></div>
Junio C Hamano9882a522007-04-27 08:22:22392</li>
393<li>
394<p>
395/regex/
396</p>
Junio C Hamanoba4b9282008-07-06 05:20:31397<div class="para"><p>This form will use the first line matching the given
Junio C Hamano9882a522007-04-27 08:22:22398POSIX regex. If &lt;end&gt; is a regex, it will search
Junio C Hamanoba4b9282008-07-06 05:20:31399starting at the line given by &lt;start&gt;.</p></div>
Junio C Hamano9882a522007-04-27 08:22:22400</li>
401<li>
402<p>
403+offset or -offset
404</p>
Junio C Hamanoba4b9282008-07-06 05:20:31405<div class="para"><p>This is only valid for &lt;end&gt; and will specify a number
406of lines before or after the line given by &lt;start&gt;.</p></div>
Junio C Hamano9882a522007-04-27 08:22:22407</li>
Junio C Hamanoba4b9282008-07-06 05:20:31408</ul></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50409</dd>
410<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11411-l
Junio C Hamanob33fb4f2006-04-18 21:30:51412</dt>
413<dd>
414<p>
Junio C Hamano3fd90c82006-06-18 00:22:01415 Show long rev (Default: off).
416</p>
417</dd>
418<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11419-t
Junio C Hamano3fd90c82006-06-18 00:22:01420</dt>
421<dd>
422<p>
423 Show raw timestamp (Default: off).
Junio C Hamanob33fb4f2006-04-18 21:30:51424</p>
425</dd>
426<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11427-S &lt;revs-file&gt;
Junio C Hamanob33fb4f2006-04-18 21:30:51428</dt>
429<dd>
430<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41431 Use revisions from revs-file instead of calling <a href="git-rev-list.html">git-rev-list(1)</a>.
Junio C Hamanob33fb4f2006-04-18 21:30:51432</p>
433</dd>
434<dt>
Junio C Hamanoa6455f62009-02-20 08:33:08435--reverse
436</dt>
437<dd>
438<p>
439 Walk history forward instead of backward. Instead of showing
440 the revision in which a line appeared, this shows the last
441 revision in which a line has existed. This requires a range of
442 revision like START..END where the path to blame exists in
443 START.
444</p>
445</dd>
446<dt>
Junio C Hamanoeb415992008-06-08 22:49:47447-p
448</dt>
449<dt>
450--porcelain
Junio C Hamanoff4b4312006-10-25 22:55:31451</dt>
452<dd>
453<p>
454 Show in a format designed for machine consumption.
455</p>
456</dd>
457<dt>
Junio C Hamano5a702332007-01-28 20:55:22458--incremental
459</dt>
460<dd>
461<p>
462 Show the result incrementally in a format designed for
463 machine consumption.
464</p>
465</dd>
466<dt>
Junio C Hamanoaa17c7c2008-11-03 04:36:58467--encoding=&lt;encoding&gt;
468</dt>
469<dd>
470<p>
471 Specifies the encoding used to output author names
472 and commit summaries. Setting it to <tt>none</tt> makes blame
473 output unconverted data. For more information see the
474 discussion about encoding in the <a href="git-log.html">git-log(1)</a>
475 manual page.
476</p>
477</dd>
478<dt>
Junio C Hamano42f855f2007-02-06 00:09:38479--contents &lt;file&gt;
480</dt>
481<dd>
482<p>
483 When &lt;rev&gt; is not specified, the command annotates the
484 changes starting backwards from the working tree copy.
485 This flag makes the command pretend as if the working
Junio C Hamano49dccaf2008-02-10 10:48:01486 tree copy has the contents of the named file (specify
Junio C Hamano42f855f2007-02-06 00:09:38487 <tt>-</tt> to make the command read from the standard input).
488</p>
489</dd>
490<dt>
Junio C Hamanoea6a7642009-03-11 23:56:19491--date &lt;format&gt;
492</dt>
493<dd>
494<p>
495 The value is one of the following alternatives:
496 {relative,local,default,iso,rfc,short}. If --date is not
497 provided, the value of the blame.date config variable is
498 used. If the blame.date config variable is also not set, the
499 iso format is used. For more information, See the discussion
500 of the --date option at <a href="git-log.html">git-log(1)</a>.
501</p>
502</dd>
503<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11504-M|&lt;num&gt;|
Junio C Hamanoe1aa7472006-11-09 07:37:50505</dt>
506<dd>
507<p>
508 Detect moving lines in the file as well. When a commit
509 moves a block of lines in a file (e.g. the original file
510 has A and then B, and the commit changes it to B and
Junio C Hamano7924d5e2009-03-03 08:28:48511 then A), the traditional <em>blame</em> algorithm typically blames
Junio C Hamanoe1aa7472006-11-09 07:37:50512 the lines that were moved up (i.e. B) to the parent and
513 assigns blame to the lines that were moved down (i.e. A)
Junio C Hamano0e3cb532007-04-17 08:28:11514 to the child commit. With this option, both groups of lines
515 are blamed on the parent.
Junio C Hamanoe1aa7472006-11-09 07:37:50516</p>
Junio C Hamanoba4b9282008-07-06 05:20:31517<div class="para"><p>&lt;num&gt; is optional but it is the lower bound on the number of
Junio C Hamano0e3cb532007-04-17 08:28:11518alphanumeric characters that git must detect as moving
519within a file for it to associate those lines with the parent
Junio C Hamanoba4b9282008-07-06 05:20:31520commit.</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50521</dd>
522<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11523-C|&lt;num&gt;|
Junio C Hamanoe1aa7472006-11-09 07:37:50524</dt>
525<dd>
526<p>
527 In addition to <tt>-M</tt>, detect lines copied from other
528 files that were modified in the same commit. This is
529 useful when you reorganize your program and move code
530 around across files. When this option is given twice,
Junio C Hamano7924d5e2009-03-03 08:28:48531 the command additionally looks for copies from all other
532 files in the parent for the commit that creates the file.
Junio C Hamanoe1aa7472006-11-09 07:37:50533</p>
Junio C Hamanoba4b9282008-07-06 05:20:31534<div class="para"><p>&lt;num&gt; is optional but it is the lower bound on the number of
Junio C Hamano0e3cb532007-04-17 08:28:11535alphanumeric characters that git must detect as moving
536between files for it to associate those lines with the parent
Junio C Hamanoba4b9282008-07-06 05:20:31537commit.</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50538</dd>
539<dt>
Junio C Hamanoeb415992008-06-08 22:49:47540-h
541</dt>
542<dt>
543--help
Junio C Hamanob33fb4f2006-04-18 21:30:51544</dt>
545<dd>
546<p>
547 Show help message.
548</p>
549</dd>
Junio C Hamano0e3cb532007-04-17 08:28:11550<dt>
551-c
552</dt>
553<dd>
554<p>
555 Use the same output mode as <a href="git-annotate.html">git-annotate(1)</a> (Default: off).
556</p>
557</dd>
558<dt>
559--score-debug
560</dt>
561<dd>
562<p>
563 Include debugging information related to the movement of
564 lines between files (see <tt>-C</tt>) and lines moved within a
565 file (see <tt>-M</tt>). The first number listed is the score.
566 This is the number of alphanumeric characters detected
Junio C Hamanofd83b8e2009-03-22 08:21:41567 as having been moved between or within files. This must be above
Junio C Hamanoba4b9282008-07-06 05:20:31568 a certain threshold for <em>git-blame</em> to consider those lines
Junio C Hamano0e3cb532007-04-17 08:28:11569 of code to have been moved.
570</p>
571</dd>
572<dt>
Junio C Hamanoeb415992008-06-08 22:49:47573-f
574</dt>
575<dt>
576--show-name
Junio C Hamano0e3cb532007-04-17 08:28:11577</dt>
578<dd>
579<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41580 Show the filename in the original commit. By default
581 the filename is shown if there is any line that came from a
582 file with a different name, due to rename detection.
Junio C Hamano0e3cb532007-04-17 08:28:11583</p>
584</dd>
585<dt>
Junio C Hamanoeb415992008-06-08 22:49:47586-n
587</dt>
588<dt>
589--show-number
Junio C Hamano0e3cb532007-04-17 08:28:11590</dt>
591<dd>
592<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41593 Show the line number in the original commit (Default: off).
Junio C Hamano0e3cb532007-04-17 08:28:11594</p>
595</dd>
Junio C Hamano469d60e2007-04-29 18:30:34596<dt>
597-s
598</dt>
599<dd>
600<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41601 Suppress the author name and timestamp from the output.
Junio C Hamano469d60e2007-04-29 18:30:34602</p>
603</dd>
Junio C Hamano9e52d4e2007-06-13 08:29:33604<dt>
605-w
606</dt>
607<dd>
608<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41609 Ignore whitespace when comparing the parent's version and
610 the child's to find where the lines came from.
Junio C Hamano9e52d4e2007-06-13 08:29:33611</p>
612</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31613</dl></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51614</div>
Junio C Hamanoba4b9282008-07-06 05:20:31615<h2 id="_the_porcelain_format">THE PORCELAIN FORMAT</h2>
Junio C Hamanoff4b4312006-10-25 22:55:31616<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31617<div class="para"><p>In this format, each line is output after a header; the
618header at the minimum has the first line which has:</p></div>
619<div class="ilist"><ul>
Junio C Hamanoff4b4312006-10-25 22:55:31620<li>
621<p>
62240-byte SHA-1 of the commit the line is attributed to;
623</p>
624</li>
625<li>
626<p>
627the line number of the line in the original file;
628</p>
629</li>
630<li>
631<p>
632the line number of the line in the final file;
633</p>
634</li>
635<li>
636<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41637on a line that starts a group of lines from a different
Junio C Hamanoff4b4312006-10-25 22:55:31638 commit than the previous one, the number of lines in this
639 group. On subsequent lines this field is absent.
640</p>
641</li>
Junio C Hamanoba4b9282008-07-06 05:20:31642</ul></div>
643<div class="para"><p>This header line is followed by the following information
644at least once for each commit:</p></div>
645<div class="ilist"><ul>
Junio C Hamanoff4b4312006-10-25 22:55:31646<li>
647<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41648the author name ("author"), email ("author-mail"), time
Junio C Hamanoff4b4312006-10-25 22:55:31649 ("author-time"), and timezone ("author-tz"); similarly
650 for committer.
651</p>
652</li>
653<li>
654<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41655the filename in the commit that the line is attributed to.
Junio C Hamanoff4b4312006-10-25 22:55:31656</p>
657</li>
658<li>
659<p>
660the first line of the commit log message ("summary").
661</p>
662</li>
Junio C Hamanoba4b9282008-07-06 05:20:31663</ul></div>
664<div class="para"><p>The contents of the actual line is output after the above
Junio C Hamanoff4b4312006-10-25 22:55:31665header, prefixed by a TAB. This is to allow adding more
Junio C Hamanoba4b9282008-07-06 05:20:31666header elements later.</p></div>
Junio C Hamanoff4b4312006-10-25 22:55:31667</div>
Junio C Hamanoba4b9282008-07-06 05:20:31668<h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
Junio C Hamanoe1aa7472006-11-09 07:37:50669<div class="sectionbody">
Junio C Hamanofd83b8e2009-03-22 08:21:41670<div class="para"><p>Unlike <em>git-blame</em> and <em>git-annotate</em> in older versions of git, the extent
671of the annotation can be limited to both line ranges and revision
Junio C Hamanoe1aa7472006-11-09 07:37:50672ranges. When you are interested in finding the origin for
Junio C Hamanofd83b8e2009-03-22 08:21:41673lines 40-60 for file <tt>foo</tt>, you can use the <tt>-L</tt> option like so
Junio C Hamanoe58607f2007-01-17 23:27:45674(they mean the same thing &#8212; both ask for 21 lines starting at
Junio C Hamanoba4b9282008-07-06 05:20:31675line 40):</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50676<div class="literalblock">
677<div class="content">
Junio C Hamanoe58607f2007-01-17 23:27:45678<pre><tt>git blame -L 40,60 foo
679git blame -L 40,+21 foo</tt></pre>
Junio C Hamanoe1aa7472006-11-09 07:37:50680</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41681<div class="para"><p>Also you can use a regular expression to specify the line range:</p></div>
Junio C Hamano4a345d22006-11-09 18:45:32682<div class="literalblock">
683<div class="content">
684<pre><tt>git blame -L '/^sub hello {/,/^}$/' foo</tt></pre>
685</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41686<div class="para"><p>which limits the annotation to the body of the <tt>hello</tt> subroutine.</p></div>
687<div class="para"><p>When you are not interested in changes older than version
Junio C Hamanoe1aa7472006-11-09 07:37:50688v2.6.18, or changes older than 3 weeks, you can use revision
Junio C Hamanoba4b9282008-07-06 05:20:31689range specifiers similar to <em>git-rev-list</em>:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50690<div class="literalblock">
691<div class="content">
692<pre><tt>git blame v2.6.18.. -- foo
693git blame --since=3.weeks -- foo</tt></pre>
694</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31695<div class="para"><p>When revision range specifiers are used to limit the annotation,
Junio C Hamanoe1aa7472006-11-09 07:37:50696lines that have not changed since the range boundary (either the
697commit v2.6.18 or the most recent commit that is more than 3
698weeks old in the above example) are blamed for that range
Junio C Hamanoba4b9282008-07-06 05:20:31699boundary commit.</p></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41700<div class="para"><p>A particularly useful way is to see if an added file has lines
Junio C Hamanoe1aa7472006-11-09 07:37:50701created by copy-and-paste from existing files. Sometimes this
702indicates that the developer was being sloppy and did not
703refactor the code properly. You can first find the commit that
Junio C Hamanoba4b9282008-07-06 05:20:31704introduced the file with:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50705<div class="literalblock">
706<div class="content">
707<pre><tt>git log --diff-filter=A --pretty=short -- foo</tt></pre>
708</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31709<div class="para"><p>and then annotate the change between the commit and its
710parents, using <tt>commit&#94;!</tt> notation:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50711<div class="literalblock">
712<div class="content">
713<pre><tt>git blame -C -C -f $commit^! -- foo</tt></pre>
714</div></div>
715</div>
Junio C Hamanoba4b9282008-07-06 05:20:31716<h2 id="_incremental_output">INCREMENTAL OUTPUT</h2>
Junio C Hamano5a702332007-01-28 20:55:22717<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31718<div class="para"><p>When called with <tt>--incremental</tt> option, the command outputs the
Junio C Hamano5a702332007-01-28 20:55:22719result as it is built. The output generally will talk about
720lines touched by more recent commits first (i.e. the lines will
721be annotated out of order) and is meant to be used by
Junio C Hamanoba4b9282008-07-06 05:20:31722interactive viewers.</p></div>
723<div class="para"><p>The output format is similar to the Porcelain format, but it
Junio C Hamano5a702332007-01-28 20:55:22724does not contain the actual lines from the file that is being
Junio C Hamanoba4b9282008-07-06 05:20:31725annotated.</p></div>
726<div class="olist"><ol>
Junio C Hamano5a702332007-01-28 20:55:22727<li>
728<p>
729Each blame entry always starts with a line of:
730</p>
731<div class="literalblock">
732<div class="content">
733<pre><tt>&lt;40-byte hex sha1&gt; &lt;sourceline&gt; &lt;resultline&gt; &lt;num_lines&gt;</tt></pre>
734</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31735<div class="para"><p>Line numbers count from 1.</p></div>
Junio C Hamano5a702332007-01-28 20:55:22736</li>
737<li>
738<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41739The first time that a commit shows up in the stream, it has various
Junio C Hamano5a702332007-01-28 20:55:22740 other information about it printed out with a one-word tag at the
Junio C Hamanofd83b8e2009-03-22 08:21:41741 beginning of each line describing the extra commit information (author,
742 email, committer, dates, summary, etc.).
Junio C Hamano5a702332007-01-28 20:55:22743</p>
744</li>
745<li>
746<p>
Junio C Hamanofd83b8e2009-03-22 08:21:41747Unlike the Porcelain format, the filename information is always
Junio C Hamano5a702332007-01-28 20:55:22748 given and terminates the entry:
749</p>
750<div class="literalblock">
751<div class="content">
752<pre><tt>"filename" &lt;whitespace-quoted-filename-goes-here&gt;</tt></pre>
753</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41754<div class="para"><p>and thus it is really quite easy to parse for some line- and word-oriented
Junio C Hamanoba4b9282008-07-06 05:20:31755parser (which should be quite natural for most scripting languages).</p></div>
Junio C Hamano5a702332007-01-28 20:55:22756<div class="admonitionblock">
757<table><tr>
758<td class="icon">
759<div class="title">Note</div>
760</td>
761<td class="content">For people who do parsing: to make it more robust, just ignore any
Junio C Hamanofd83b8e2009-03-22 08:21:41762lines between the first and last one ("&lt;sha1&gt;" and "filename" lines)
763where you do not recognize the tag words (or care about that particular
Junio C Hamano5a702332007-01-28 20:55:22764one) at the beginning of the "extended information" lines. That way, if
765there is ever added information (like the commit encoding or extended
Junio C Hamanofd83b8e2009-03-22 08:21:41766commit commentary), a blame viewer will not care.</td>
Junio C Hamano5a702332007-01-28 20:55:22767</tr></table>
768</div>
769</li>
Junio C Hamanoba4b9282008-07-06 05:20:31770</ol></div>
Junio C Hamano5a702332007-01-28 20:55:22771</div>
Junio C Hamano8bc410e2009-02-15 10:38:19772<h2 id="_mapping_authors">MAPPING AUTHORS</h2>
773<div class="sectionbody">
774<div class="para"><p>If the file <tt>.mailmap</tt> exists at the toplevel of the repository, or at
775the location pointed to by the mailmap.file configuration option, it
776is used to map author and committer names and email addresses to
777canonical real names and email addresses.</p></div>
778<div class="para"><p>In the simple form, each line in the file consists of the canonical
779real name of an author, whitespace, and an email address used in the
Junio C Hamanofd83b8e2009-03-22 08:21:41780commit (enclosed by <em>&lt;</em> and <em>&gt;</em>) to map to the name. For example:</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19781<div class="literalblock">
782<div class="content">
783<pre><tt>Proper Name &lt;commit@email.xx&gt;</tt></pre>
784</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41785<div class="para"><p>The more complex forms are:</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19786<div class="literalblock">
787<div class="content">
788<pre><tt>&lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
789</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41790<div class="para"><p>which allows mailmap to replace only the email part of a commit, and:</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19791<div class="literalblock">
792<div class="content">
793<pre><tt>Proper Name &lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
794</div></div>
795<div class="para"><p>which allows mailmap to replace both the name and the email of a
Junio C Hamanofd83b8e2009-03-22 08:21:41796commit matching the specified commit email address, and:</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19797<div class="literalblock">
798<div class="content">
799<pre><tt>Proper Name &lt;proper@email.xx&gt; Commit Name &lt;commit@email.xx&gt;</tt></pre>
800</div></div>
801<div class="para"><p>which allows mailmap to replace both the name and the email of a
802commit matching both the specified commit name and email address.</p></div>
803<div class="para"><p>Example 1: Your history contains commits by two authors, Jane
804and Joe, whose names appear in the repository under several forms:</p></div>
805<div class="listingblock">
806<div class="content">
807<pre><tt>Joe Developer &lt;joe@example.com&gt;
808Joe R. Developer &lt;joe@example.com&gt;
809Jane Doe &lt;jane@example.com&gt;
810Jane Doe &lt;jane@laptop.(none)&gt;
811Jane D. &lt;jane@desktop.(none)&gt;</tt></pre>
812</div></div>
813<div class="para"><p>Now suppose that Joe wants his middle name initial used, and Jane
814prefers her family name fully spelled out. A proper <tt>.mailmap</tt> file
815would look like:</p></div>
816<div class="listingblock">
817<div class="content">
818<pre><tt>Jane Doe &lt;jane@desktop.(none)&gt;
819Joe R. Developer &lt;joe@example.com&gt;</tt></pre>
820</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41821<div class="para"><p>Note how there is no need for an entry for &lt;jane@laptop.(none)&gt;, because the
822real name of that author is already correct.</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19823<div class="para"><p>Example 2: Your repository contains commits from the following
824authors:</p></div>
825<div class="listingblock">
826<div class="content">
827<pre><tt>nick1 &lt;bugs@company.xx&gt;
828nick2 &lt;bugs@company.xx&gt;
829nick2 &lt;nick2@company.xx&gt;
830santa &lt;me@company.xx&gt;
831claus &lt;me@company.xx&gt;
832CTO &lt;cto@coompany.xx&gt;</tt></pre>
833</div></div>
Junio C Hamanofd83b8e2009-03-22 08:21:41834<div class="para"><p>Then you might want a <tt>.mailmap</tt> file that looks like:</p></div>
Junio C Hamano8bc410e2009-02-15 10:38:19835<div class="listingblock">
836<div class="content">
837<pre><tt>&lt;cto@company.xx&gt; &lt;cto@coompany.xx&gt;
838Some Dude &lt;some@dude.xx&gt; nick1 &lt;bugs@company.xx&gt;
839Other Author &lt;other@author.xx&gt; nick2 &lt;bugs@company.xx&gt;
840Other Author &lt;other@author.xx&gt; &lt;nick2@company.xx&gt;
841Santa Claus &lt;santa.claus@northpole.xx&gt; &lt;me@company.xx&gt;</tt></pre>
842</div></div>
843<div class="para"><p>Use hash <em>#</em> for comments that are either on their own line, or after
844the email address.</p></div>
845</div>
Junio C Hamanoba4b9282008-07-06 05:20:31846<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51847<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31848<div class="para"><p><a href="git-annotate.html">git-annotate(1)</a></p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51849</div>
Junio C Hamanoba4b9282008-07-06 05:20:31850<h2 id="_author">AUTHOR</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51851<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44852<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51853</div>
Junio C Hamanoba4b9282008-07-06 05:20:31854<h2 id="_git">GIT</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51855<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31856<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51857</div>
858<div id="footer">
859<div id="footer-text">
Junio C Hamano73d812c2009-07-01 02:33:06860Last updated 2009-07-01 02:30:43 UTC
Junio C Hamanob33fb4f2006-04-18 21:30:51861</div>
862</div>
863</body>
864</html>