blob: 75cd355909e7a50188d150d6613bff3a0ff1d816 [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" />
6<meta name="generator" content="AsciiDoc 7.0.2" />
7<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
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-blame(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-blame(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-blame -
Junio C Hamano6b2cee12006-08-26 08:43:31269 Show what revision and author last modified each line of a file
Junio C Hamanob33fb4f2006-04-18 21:30:51270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamanoe1aa7472006-11-09 07:37:50275<div class="verseblock">
276<div class="content"><em>git-blame</em> [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S &lt;revs-file&gt;]
277 [-M] [-C] [-C] [--since=&lt;date&gt;] [&lt;rev&gt;] [--] &lt;file&gt;</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51278</div>
279<h2>DESCRIPTION</h2>
280<div class="sectionbody">
Junio C Hamano6b2cee12006-08-26 08:43:31281<p>Annotates each line in the given file with information from the revision which
282last modified the line. Optionally, start annotating from the given revision.</p>
Junio C Hamanoe1aa7472006-11-09 07:37:50283<p>Also it can limit the range of lines annotated.</p>
Junio C Hamano6b2cee12006-08-26 08:43:31284<p>This report doesn't tell you anything about lines which have been deleted or
285replaced; you need to use a tool such as <a href="git-diff.html">git-diff(1)</a> or the "pickaxe"
286interface briefly mentioned in the following paragraph.</p>
287<p>Apart from supporting file annotation, git also supports searching the
288development history for when a code snippet occured in a change. This makes it
289possible to track when a code snippet was added to a file, moved or copied
290between files, and eventually deleted or replaced. It works by searching for
291a text string in the diff. A small example:</p>
292<div class="listingblock">
293<div class="content">
294<pre><tt>$ git log --pretty=oneline -S'blame_usage'
2955040f17eba15504bad66b14a645bddd9b015ebb7 blame -S &lt;ancestry-file&gt;
296ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</tt></pre>
297</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51298</div>
299<h2>OPTIONS</h2>
300<div class="sectionbody">
301<dl>
302<dt>
Junio C Hamano341071d2006-06-04 07:24:48303-c, --compatibility
Junio C Hamanob33fb4f2006-04-18 21:30:51304</dt>
305<dd>
306<p>
Junio C Hamano6b2cee12006-08-26 08:43:31307 Use the same output mode as <a href="git-annotate.html">git-annotate(1)</a> (Default: off).
Junio C Hamanob33fb4f2006-04-18 21:30:51308</p>
309</dd>
310<dt>
Junio C Hamanoe1aa7472006-11-09 07:37:50311-L n,m
312</dt>
313<dd>
314<p>
Junio C Hamano4a345d22006-11-09 18:45:32315 Annotate only the specified line range (lines count from 1).
Junio C Hamanoe1aa7472006-11-09 07:37:50316</p>
317</dd>
318<dt>
Junio C Hamanob33fb4f2006-04-18 21:30:51319-l, --long
320</dt>
321<dd>
322<p>
Junio C Hamano3fd90c82006-06-18 00:22:01323 Show long rev (Default: off).
324</p>
325</dd>
326<dt>
327-t, --time
328</dt>
329<dd>
330<p>
331 Show raw timestamp (Default: off).
Junio C Hamanob33fb4f2006-04-18 21:30:51332</p>
333</dd>
334<dt>
335-S, --rev-file &lt;revs-file&gt;
336</dt>
337<dd>
338<p>
Junio C Hamano6b2cee12006-08-26 08:43:31339 Use revs from revs-file instead of calling <a href="git-rev-list.html">git-rev-list(1)</a>.
Junio C Hamanob33fb4f2006-04-18 21:30:51340</p>
341</dd>
342<dt>
Junio C Hamanoff4b4312006-10-25 22:55:31343-f, --show-name
344</dt>
345<dd>
346<p>
347 Show filename in the original commit. By default
348 filename is shown if there is any line that came from a
349 file with different name, due to rename detection.
350</p>
351</dd>
352<dt>
353-n, --show-number
354</dt>
355<dd>
356<p>
357 Show line number in the original commit (Default: off).
358</p>
359</dd>
360<dt>
361-p, --porcelain
362</dt>
363<dd>
364<p>
365 Show in a format designed for machine consumption.
366</p>
367</dd>
368<dt>
Junio C Hamanoe1aa7472006-11-09 07:37:50369-M
370</dt>
371<dd>
372<p>
373 Detect moving lines in the file as well. When a commit
374 moves a block of lines in a file (e.g. the original file
375 has A and then B, and the commit changes it to B and
376 then A), traditional <em>blame</em> algorithm typically blames
377 the lines that were moved up (i.e. B) to the parent and
378 assigns blame to the lines that were moved down (i.e. A)
379 to the child commit. With this option, both groups of
380 lines are blamed on the parent.
381</p>
382</dd>
383<dt>
384-C
385</dt>
386<dd>
387<p>
388 In addition to <tt>-M</tt>, detect lines copied from other
389 files that were modified in the same commit. This is
390 useful when you reorganize your program and move code
391 around across files. When this option is given twice,
392 the command looks for copies from all other files in the
393 parent for the commit that creates the file in addition.
394</p>
395</dd>
396<dt>
Junio C Hamanob33fb4f2006-04-18 21:30:51397-h, --help
398</dt>
399<dd>
400<p>
401 Show help message.
402</p>
403</dd>
404</dl>
405</div>
Junio C Hamanoff4b4312006-10-25 22:55:31406<h2>THE PORCELAIN FORMAT</h2>
407<div class="sectionbody">
408<p>In this format, each line is output after a header; the
409header at the minumum has the first line which has:</p>
410<ul>
411<li>
412<p>
41340-byte SHA-1 of the commit the line is attributed to;
414</p>
415</li>
416<li>
417<p>
418the line number of the line in the original file;
419</p>
420</li>
421<li>
422<p>
423the line number of the line in the final file;
424</p>
425</li>
426<li>
427<p>
428on a line that starts a group of line from a different
429 commit than the previous one, the number of lines in this
430 group. On subsequent lines this field is absent.
431</p>
432</li>
433</ul>
434<p>This header line is followed by the following information
435at least once for each commit:</p>
436<ul>
437<li>
438<p>
439author name ("author"), email ("author-mail"), time
440 ("author-time"), and timezone ("author-tz"); similarly
441 for committer.
442</p>
443</li>
444<li>
445<p>
446filename in the commit the line is attributed to.
447</p>
448</li>
449<li>
450<p>
451the first line of the commit log message ("summary").
452</p>
453</li>
454</ul>
455<p>The contents of the actual line is output after the above
456header, prefixed by a TAB. This is to allow adding more
457header elements later.</p>
458</div>
Junio C Hamanoe1aa7472006-11-09 07:37:50459<h2>SPECIFIYING RANGES</h2>
460<div class="sectionbody">
461<p>Unlike <tt>git-blame</tt> and <tt>git-annotate</tt> in older git, the extent
462of annotation can be limited to both line ranges and revision
463ranges. When you are interested in finding the origin for
464ll. 40-60 for file <tt>foo</tt>, you can use <tt>-L</tt> option like this:</p>
465<div class="literalblock">
466<div class="content">
467<pre><tt>git blame -L 40,60 foo</tt></pre>
468</div></div>
Junio C Hamano4a345d22006-11-09 18:45:32469<p>Also you can use regular expression to specify the line range.</p>
470<div class="literalblock">
471<div class="content">
472<pre><tt>git blame -L '/^sub hello {/,/^}$/' foo</tt></pre>
473</div></div>
474<p>would limit the annotation to the body of <tt>hello</tt> subroutine.</p>
Junio C Hamanoe1aa7472006-11-09 07:37:50475<p>When you are not interested in changes older than the version
476v2.6.18, or changes older than 3 weeks, you can use revision
477range specifiers similar to <tt>git-rev-list</tt>:</p>
478<div class="literalblock">
479<div class="content">
480<pre><tt>git blame v2.6.18.. -- foo
481git blame --since=3.weeks -- foo</tt></pre>
482</div></div>
483<p>When revision range specifiers are used to limit the annotation,
484lines that have not changed since the range boundary (either the
485commit v2.6.18 or the most recent commit that is more than 3
486weeks old in the above example) are blamed for that range
487boundary commit.</p>
488<p>A particularly useful way is to see if an added file have lines
489created by copy-and-paste from existing files. Sometimes this
490indicates that the developer was being sloppy and did not
491refactor the code properly. You can first find the commit that
492introduced the file with:</p>
493<div class="literalblock">
494<div class="content">
495<pre><tt>git log --diff-filter=A --pretty=short -- foo</tt></pre>
496</div></div>
497<p>and then annotate the change between the commit and its
498parents, using <tt>commit^!</tt> notation:</p>
499<div class="literalblock">
500<div class="content">
501<pre><tt>git blame -C -C -f $commit^! -- foo</tt></pre>
502</div></div>
503</div>
Junio C Hamanob33fb4f2006-04-18 21:30:51504<h2>SEE ALSO</h2>
505<div class="sectionbody">
506<p><a href="git-annotate.html">git-annotate(1)</a></p>
507</div>
508<h2>AUTHOR</h2>
509<div class="sectionbody">
Junio C Hamanoe1aa7472006-11-09 07:37:50510<p>Written by Junio C Hamano &lt;junkio@cox.net&gt;</p>
Junio C Hamanob33fb4f2006-04-18 21:30:51511</div>
512<h2>GIT</h2>
513<div class="sectionbody">
514<p>Part of the <a href="git.html">git(7)</a> suite</p>
515</div>
516<div id="footer">
517<div id="footer-text">
Junio C Hamano4a345d22006-11-09 18:45:32518Last updated 09-Nov-2006 18:45:28 UTC
Junio C Hamanob33fb4f2006-04-18 21:30:51519</div>
520</div>
521</body>
522</html>