Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 1 | <!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 */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, 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 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#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 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.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 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.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 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | include::./stylesheets/xhtml11-manpage.css[] |
| 230 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 231 | |
| 232 | div.sidebar-content { |
| 233 | background: #ffffee; |
| 234 | border: 1px solid silver; |
| 235 | padding: 0.5em; |
| 236 | } |
| 237 | div.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 | |
| 244 | div.listingblock div.content { |
| 245 | border: 1px solid silver; |
| 246 | background: #f4f4f4; |
| 247 | padding: 0.5em; |
| 248 | } |
| 249 | |
| 250 | div.quoteblock-content { |
| 251 | padding-left: 2.0em; |
| 252 | } |
| 253 | |
| 254 | div.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> |
| 264 | git-blame(1) Manual Page |
| 265 | </h1> |
| 266 | <h2>NAME</h2> |
| 267 | <div class="sectionbody"> |
| 268 | <p>git-blame - |
Junio C Hamano | 6b2cee1 | 2006-08-26 08:43:31 | [diff] [blame] | 269 | Show what revision and author last modified each line of a file |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 270 | </p> |
| 271 | </div> |
| 272 | </div> |
| 273 | <h2>SYNOPSIS</h2> |
| 274 | <div class="sectionbody"> |
Junio C Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 275 | <div class="verseblock"> |
| 276 | <div class="content"><em>git-blame</em> [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] |
| 277 | [-M] [-C] [-C] [--since=<date>] [<rev>] [--] <file></div></div> |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 278 | </div> |
| 279 | <h2>DESCRIPTION</h2> |
| 280 | <div class="sectionbody"> |
Junio C Hamano | 6b2cee1 | 2006-08-26 08:43:31 | [diff] [blame] | 281 | <p>Annotates each line in the given file with information from the revision which |
| 282 | last modified the line. Optionally, start annotating from the given revision.</p> |
Junio C Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 283 | <p>Also it can limit the range of lines annotated.</p> |
Junio C Hamano | 6b2cee1 | 2006-08-26 08:43:31 | [diff] [blame] | 284 | <p>This report doesn't tell you anything about lines which have been deleted or |
| 285 | replaced; you need to use a tool such as <a href="git-diff.html">git-diff(1)</a> or the "pickaxe" |
| 286 | interface briefly mentioned in the following paragraph.</p> |
| 287 | <p>Apart from supporting file annotation, git also supports searching the |
| 288 | development history for when a code snippet occured in a change. This makes it |
| 289 | possible to track when a code snippet was added to a file, moved or copied |
| 290 | between files, and eventually deleted or replaced. It works by searching for |
| 291 | a 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' |
| 295 | 5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S <ancestry-file> |
| 296 | ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</tt></pre> |
| 297 | </div></div> |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 298 | </div> |
| 299 | <h2>OPTIONS</h2> |
| 300 | <div class="sectionbody"> |
| 301 | <dl> |
| 302 | <dt> |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 303 | -c, --compatibility |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 304 | </dt> |
| 305 | <dd> |
| 306 | <p> |
Junio C Hamano | 6b2cee1 | 2006-08-26 08:43:31 | [diff] [blame] | 307 | Use the same output mode as <a href="git-annotate.html">git-annotate(1)</a> (Default: off). |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 308 | </p> |
| 309 | </dd> |
| 310 | <dt> |
Junio C Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 311 | -L n,m |
| 312 | </dt> |
| 313 | <dd> |
| 314 | <p> |
Junio C Hamano | 4a345d2 | 2006-11-09 18:45:32 | [diff] [blame] | 315 | Annotate only the specified line range (lines count from 1). |
Junio C Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 316 | </p> |
| 317 | </dd> |
| 318 | <dt> |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 319 | -l, --long |
| 320 | </dt> |
| 321 | <dd> |
| 322 | <p> |
Junio C Hamano | 3fd90c8 | 2006-06-18 00:22:01 | [diff] [blame] | 323 | 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 Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 332 | </p> |
| 333 | </dd> |
| 334 | <dt> |
| 335 | -S, --rev-file <revs-file> |
| 336 | </dt> |
| 337 | <dd> |
| 338 | <p> |
Junio C Hamano | 6b2cee1 | 2006-08-26 08:43:31 | [diff] [blame] | 339 | Use revs from revs-file instead of calling <a href="git-rev-list.html">git-rev-list(1)</a>. |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 340 | </p> |
| 341 | </dd> |
| 342 | <dt> |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 343 | -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 Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 369 | -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 Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 397 | -h, --help |
| 398 | </dt> |
| 399 | <dd> |
| 400 | <p> |
| 401 | Show help message. |
| 402 | </p> |
| 403 | </dd> |
| 404 | </dl> |
| 405 | </div> |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 406 | <h2>THE PORCELAIN FORMAT</h2> |
| 407 | <div class="sectionbody"> |
| 408 | <p>In this format, each line is output after a header; the |
| 409 | header at the minumum has the first line which has:</p> |
| 410 | <ul> |
| 411 | <li> |
| 412 | <p> |
| 413 | 40-byte SHA-1 of the commit the line is attributed to; |
| 414 | </p> |
| 415 | </li> |
| 416 | <li> |
| 417 | <p> |
| 418 | the line number of the line in the original file; |
| 419 | </p> |
| 420 | </li> |
| 421 | <li> |
| 422 | <p> |
| 423 | the line number of the line in the final file; |
| 424 | </p> |
| 425 | </li> |
| 426 | <li> |
| 427 | <p> |
| 428 | on 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 |
| 435 | at least once for each commit:</p> |
| 436 | <ul> |
| 437 | <li> |
| 438 | <p> |
| 439 | author 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> |
| 446 | filename in the commit the line is attributed to. |
| 447 | </p> |
| 448 | </li> |
| 449 | <li> |
| 450 | <p> |
| 451 | the 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 |
| 456 | header, prefixed by a TAB. This is to allow adding more |
| 457 | header elements later.</p> |
| 458 | </div> |
Junio C Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 459 | <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 |
| 462 | of annotation can be limited to both line ranges and revision |
| 463 | ranges. When you are interested in finding the origin for |
| 464 | ll. 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 Hamano | 4a345d2 | 2006-11-09 18:45:32 | [diff] [blame] | 469 | <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 Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 475 | <p>When you are not interested in changes older than the version |
| 476 | v2.6.18, or changes older than 3 weeks, you can use revision |
| 477 | range 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 |
| 481 | git blame --since=3.weeks -- foo</tt></pre> |
| 482 | </div></div> |
| 483 | <p>When revision range specifiers are used to limit the annotation, |
| 484 | lines that have not changed since the range boundary (either the |
| 485 | commit v2.6.18 or the most recent commit that is more than 3 |
| 486 | weeks old in the above example) are blamed for that range |
| 487 | boundary commit.</p> |
| 488 | <p>A particularly useful way is to see if an added file have lines |
| 489 | created by copy-and-paste from existing files. Sometimes this |
| 490 | indicates that the developer was being sloppy and did not |
| 491 | refactor the code properly. You can first find the commit that |
| 492 | introduced 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 |
| 498 | parents, 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 Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 504 | <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 Hamano | e1aa747 | 2006-11-09 07:37:50 | [diff] [blame] | 510 | <p>Written by Junio C Hamano <junkio@cox.net></p> |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 511 | </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 Hamano | 4a345d2 | 2006-11-09 18:45:32 | [diff] [blame] | 518 | Last updated 09-Nov-2006 18:45:28 UTC |
Junio C Hamano | b33fb4f | 2006-04-18 21:30:51 | [diff] [blame] | 519 | </div> |
| 520 | </div> |
| 521 | </body> |
| 522 | </html> |