Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [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" /> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.2.5" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 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 | |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 19 | a { |
| 20 | color: blue; |
| 21 | text-decoration: underline; |
| 22 | } |
| 23 | a:visited { |
| 24 | color: fuchsia; |
| 25 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 26 | |
| 27 | em { |
| 28 | font-style: italic; |
| 29 | } |
| 30 | |
| 31 | strong { |
| 32 | font-weight: bold; |
| 33 | } |
| 34 | |
| 35 | tt { |
| 36 | color: navy; |
| 37 | } |
| 38 | |
| 39 | h1, 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 Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 47 | h1, h2, h3 { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 48 | border-bottom: 2px solid silver; |
| 49 | } |
| 50 | h2 { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 51 | padding-top: 0.5em; |
| 52 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 53 | h3 { |
| 54 | float: left; |
| 55 | } |
| 56 | h3 + * { |
| 57 | clear: left; |
| 58 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 59 | |
| 60 | div.sectionbody { |
| 61 | font-family: serif; |
| 62 | margin-left: 0; |
| 63 | } |
| 64 | |
| 65 | hr { |
| 66 | border: 1px solid silver; |
| 67 | } |
| 68 | |
| 69 | p { |
| 70 | margin-top: 0.5em; |
| 71 | margin-bottom: 0.5em; |
| 72 | } |
| 73 | |
| 74 | pre { |
| 75 | padding: 0; |
| 76 | margin: 0; |
| 77 | } |
| 78 | |
| 79 | span#author { |
| 80 | color: #527bbd; |
| 81 | font-family: sans-serif; |
| 82 | font-weight: bold; |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 83 | font-size: 1.1em; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 84 | } |
| 85 | span#email { |
| 86 | } |
| 87 | span#revision { |
| 88 | font-family: sans-serif; |
| 89 | } |
| 90 | |
| 91 | div#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 | } |
| 98 | div#footer-text { |
| 99 | float: left; |
| 100 | padding-bottom: 0.5em; |
| 101 | } |
| 102 | div#footer-badges { |
| 103 | float: right; |
| 104 | padding-bottom: 0.5em; |
| 105 | } |
| 106 | |
| 107 | div#preamble, |
| 108 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 109 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 110 | div.admonitionblock { |
| 111 | margin-right: 10%; |
| 112 | margin-top: 1.5em; |
| 113 | margin-bottom: 1.5em; |
| 114 | } |
| 115 | div.admonitionblock { |
| 116 | margin-top: 2.5em; |
| 117 | margin-bottom: 2.5em; |
| 118 | } |
| 119 | |
| 120 | div.content { /* Block element content. */ |
| 121 | padding: 0; |
| 122 | } |
| 123 | |
| 124 | /* Block element titles. */ |
| 125 | div.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 | } |
| 132 | div.title + * { |
| 133 | margin-top: 0; |
| 134 | } |
| 135 | |
| 136 | td div.title:first-child { |
| 137 | margin-top: 0.0em; |
| 138 | } |
| 139 | div.content div.title:first-child { |
| 140 | margin-top: 0.0em; |
| 141 | } |
| 142 | div.content + div.title { |
| 143 | margin-top: 0.0em; |
| 144 | } |
| 145 | |
| 146 | div.sidebarblock > div.content { |
| 147 | background: #ffffee; |
| 148 | border: 1px solid silver; |
| 149 | padding: 0.5em; |
| 150 | } |
| 151 | |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 152 | div.listingblock { |
| 153 | margin-right: 0%; |
| 154 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 155 | div.listingblock > div.content { |
| 156 | border: 1px solid silver; |
| 157 | background: #f4f4f4; |
| 158 | padding: 0.5em; |
| 159 | } |
| 160 | |
| 161 | div.quoteblock > div.content { |
| 162 | padding-left: 2.0em; |
| 163 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 164 | |
| 165 | div.attribution { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 166 | text-align: right; |
| 167 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 168 | div.verseblock + div.attribution { |
| 169 | text-align: left; |
| 170 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 171 | |
| 172 | div.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 | } |
| 180 | div.admonitionblock td.content { |
| 181 | padding-left: 0.5em; |
| 182 | border-left: 2px solid silver; |
| 183 | } |
| 184 | |
| 185 | div.exampleblock > div.content { |
| 186 | border-left: 2px solid silver; |
| 187 | padding: 0.5em; |
| 188 | } |
| 189 | |
| 190 | div.verseblock div.content { |
| 191 | white-space: pre; |
| 192 | } |
| 193 | |
| 194 | div.imageblock div.content { padding-left: 0; } |
| 195 | div.imageblock img { border: 1px solid silver; } |
| 196 | span.image img { border-style: none; } |
| 197 | |
| 198 | dl { |
| 199 | margin-top: 0.8em; |
| 200 | margin-bottom: 0.8em; |
| 201 | } |
| 202 | dt { |
| 203 | margin-top: 0.5em; |
| 204 | margin-bottom: 0; |
| 205 | font-style: italic; |
| 206 | } |
| 207 | dd > *:first-child { |
| 208 | margin-top: 0; |
| 209 | } |
| 210 | |
| 211 | ul, ol { |
| 212 | list-style-position: outside; |
| 213 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 214 | div.olist2 ol { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 215 | list-style-type: lower-alpha; |
| 216 | } |
| 217 | |
| 218 | div.tableblock > table { |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 219 | border: 3px solid #527bbd; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 220 | } |
| 221 | thead { |
| 222 | font-family: sans-serif; |
| 223 | font-weight: bold; |
| 224 | } |
| 225 | tfoot { |
| 226 | font-weight: bold; |
| 227 | } |
| 228 | |
| 229 | div.hlist { |
| 230 | margin-top: 0.8em; |
| 231 | margin-bottom: 0.8em; |
| 232 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 233 | div.hlist td { |
| 234 | padding-bottom: 5px; |
| 235 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 236 | td.hlist1 { |
| 237 | vertical-align: top; |
| 238 | font-style: italic; |
| 239 | padding-right: 0.8em; |
| 240 | } |
| 241 | td.hlist2 { |
| 242 | vertical-align: top; |
| 243 | } |
| 244 | |
| 245 | @media print { |
| 246 | div#footer-badges { display: none; } |
| 247 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 248 | |
| 249 | div#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 | |
| 258 | div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
| 259 | margin-top: 0; |
| 260 | margin-bottom: 0; |
| 261 | } |
| 262 | div.toclevel2 { |
| 263 | margin-left: 2em; |
| 264 | font-size: 0.9em; |
| 265 | } |
| 266 | div.toclevel3 { |
| 267 | margin-left: 4em; |
| 268 | font-size: 0.9em; |
| 269 | } |
| 270 | div.toclevel4 { |
| 271 | margin-left: 6em; |
| 272 | font-size: 0.9em; |
| 273 | } |
| 274 | include1::./stylesheets/xhtml11-manpage.css[] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 275 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 276 | |
| 277 | div.sidebar-content { |
| 278 | background: #ffffee; |
| 279 | border: 1px solid silver; |
| 280 | padding: 0.5em; |
| 281 | } |
| 282 | div.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 | |
| 289 | div.listingblock div.content { |
| 290 | border: 1px solid silver; |
| 291 | background: #f4f4f4; |
| 292 | padding: 0.5em; |
| 293 | } |
| 294 | |
| 295 | div.quoteblock-content { |
| 296 | padding-left: 2.0em; |
| 297 | } |
| 298 | |
| 299 | div.exampleblock-content { |
| 300 | border-left: 2px solid silver; |
| 301 | padding-left: 0.5em; |
| 302 | } |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 303 | |
| 304 | /* IE6 sets dynamically generated links as visited. */ |
| 305 | div#toc a:visited { color: blue; } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 306 | </style> |
| 307 | <title>git-diff(1)</title> |
| 308 | </head> |
| 309 | <body> |
| 310 | <div id="header"> |
| 311 | <h1> |
| 312 | git-diff(1) Manual Page |
| 313 | </h1> |
| 314 | <h2>NAME</h2> |
| 315 | <div class="sectionbody"> |
| 316 | <p>git-diff - |
Junio C Hamano | 0107892 | 2006-03-10 00:31:47 | [diff] [blame] | 317 | Show changes between commits, commit and working tree, etc |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 318 | </p> |
| 319 | </div> |
| 320 | </div> |
| 321 | <h2>SYNOPSIS</h2> |
| 322 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 323 | <div class="para"><p><em>git diff</em> [<common diff options>] <commit>{0,2} [--] [<path>…]</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 324 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 325 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 327 | <div class="para"><p>Show changes between two trees, a tree and the working tree, a |
| 328 | tree and the index file, or the index file and the working tree.</p></div> |
| 329 | <div class="vlist"><dl> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 330 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 331 | <em>git diff</em> [--options] [--] [<path>…] |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 332 | </dt> |
| 333 | <dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 334 | <p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 335 | This form is to view the changes you made relative to |
| 336 | the index (staging area for the next commit). In other |
Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 337 | words, the differences are what you _could_ tell git to |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 338 | further add to the index but you still haven't. You can |
| 339 | stage these changes by using <a href="git-add.html">git-add(1)</a>. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 340 | </p> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 341 | <div class="para"><p>If exactly two paths are given, and at least one is untracked, |
Junio C Hamano | db911ee | 2007-02-28 08:13:52 | [diff] [blame] | 342 | compare the two files / directories. This behavior can be |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 343 | forced by --no-index.</p></div> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 344 | </dd> |
| 345 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 346 | <em>git diff</em> [--options] --cached [<commit>] [--] [<path>…] |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 347 | </dt> |
| 348 | <dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 349 | <p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 350 | This form is to view the changes you staged for the next |
Junio C Hamano | 4bf6dca | 2006-12-21 02:25:57 | [diff] [blame] | 351 | commit relative to the named <commit>. Typically you |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 352 | would want comparison with the latest commit, so if you |
| 353 | do not give <commit>, it defaults to HEAD. |
Junio C Hamano | 8b4977b | 2008-11-12 04:57:48 | [diff] [blame] | 354 | --staged is a synonym of --cached. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 355 | </p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 356 | </dd> |
| 357 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 358 | <em>git diff</em> [--options] <commit> [--] [<path>…] |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 359 | </dt> |
| 360 | <dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 361 | <p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 362 | This form is to view the changes you have in your |
| 363 | working tree relative to the named <commit>. You can |
| 364 | use HEAD to compare it with the latest commit, or a |
| 365 | branch name to compare with the tip of a different |
| 366 | branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 367 | </p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 368 | </dd> |
| 369 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 370 | <em>git diff</em> [--options] <commit> <commit> [--] [<path>…] |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 371 | </dt> |
| 372 | <dd> |
| 373 | <p> |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 374 | This is to view the changes between two arbitrary |
| 375 | <commit>. |
| 376 | </p> |
| 377 | </dd> |
| 378 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 379 | <em>git diff</em> [--options] <commit>..<commit> [--] [<path>…] |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 380 | </dt> |
| 381 | <dd> |
| 382 | <p> |
| 383 | This is synonymous to the previous form. If <commit> on |
| 384 | one side is omitted, it will have the same effect as |
| 385 | using HEAD instead. |
| 386 | </p> |
| 387 | </dd> |
| 388 | <dt> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 389 | <em>git diff</em> [--options] <commit>...<commit> [--] [<path>…] |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 390 | </dt> |
| 391 | <dd> |
| 392 | <p> |
| 393 | This form is to view the changes on the branch containing |
| 394 | and up to the second <commit>, starting at a common ancestor |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 395 | of both <commit>. "git diff A...B" is equivalent to |
| 396 | "git diff $(git-merge-base A B) B". You can omit any one |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 397 | of <commit>, which has the same effect as using HEAD instead. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 398 | </p> |
| 399 | </dd> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 400 | </dl></div> |
| 401 | <div class="para"><p>Just in case if you are doing something exotic, it should be |
Junio C Hamano | 7d9e9bd | 2007-08-29 07:31:47 | [diff] [blame] | 402 | noted that all of the <commit> in the above description, except |
| 403 | for the last two forms that use ".." notations, can be any |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 404 | <tree-ish>.</p></div> |
| 405 | <div class="para"><p>For a more complete list of ways to spell <commit>, see |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 406 | "SPECIFYING REVISIONS" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>. |
Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 407 | However, "diff" is about comparing two _endpoints_, not ranges, |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 408 | and the range notations ("<commit>..<commit>" and |
Junio C Hamano | 7d9e9bd | 2007-08-29 07:31:47 | [diff] [blame] | 409 | "<commit>...<commit>") do not mean a range as defined in the |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 410 | "SPECIFYING RANGES" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 411 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 412 | <h2 id="_options">OPTIONS</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 413 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 414 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 415 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 416 | -p |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 417 | </dt> |
| 418 | <dd> |
| 419 | <p> |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 420 | Generate patch (see section on generating patches). |
| 421 | This is the default. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 422 | </p> |
| 423 | </dd> |
| 424 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 425 | -u |
| 426 | </dt> |
| 427 | <dd> |
| 428 | <p> |
| 429 | Synonym for "-p". |
| 430 | </p> |
| 431 | </dd> |
| 432 | <dt> |
Junio C Hamano | 6936156 | 2007-07-26 02:14:34 | [diff] [blame] | 433 | -U<n> |
| 434 | </dt> |
| 435 | <dd> |
| 436 | <p> |
| 437 | Shorthand for "--unified=<n>". |
| 438 | </p> |
| 439 | </dd> |
| 440 | <dt> |
| 441 | --unified=<n> |
| 442 | </dt> |
| 443 | <dd> |
| 444 | <p> |
| 445 | Generate diffs with <n> lines of context instead of |
| 446 | the usual three. Implies "-p". |
| 447 | </p> |
| 448 | </dd> |
| 449 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 450 | --raw |
| 451 | </dt> |
| 452 | <dd> |
| 453 | <p> |
| 454 | Generate the raw format. |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 455 | |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 456 | </p> |
| 457 | </dd> |
| 458 | <dt> |
| 459 | --patch-with-raw |
| 460 | </dt> |
| 461 | <dd> |
| 462 | <p> |
| 463 | Synonym for "-p --raw". |
| 464 | </p> |
| 465 | </dd> |
| 466 | <dt> |
| 467 | --stat[=width[,name-width]] |
| 468 | </dt> |
| 469 | <dd> |
| 470 | <p> |
| 471 | Generate a diffstat. You can override the default |
| 472 | output width for 80-column terminal by "--stat=width". |
| 473 | The width of the filename part can be controlled by |
| 474 | giving another width to it separated by a comma. |
| 475 | </p> |
| 476 | </dd> |
| 477 | <dt> |
| 478 | --numstat |
| 479 | </dt> |
| 480 | <dd> |
| 481 | <p> |
| 482 | Similar to --stat, but shows number of added and |
| 483 | deleted lines in decimal notation and pathname without |
Junio C Hamano | d793de5 | 2006-12-26 09:11:43 | [diff] [blame] | 484 | abbreviation, to make it more machine friendly. For |
| 485 | binary files, outputs two <tt>-</tt> instead of saying |
| 486 | <tt>0 0</tt>. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 487 | </p> |
| 488 | </dd> |
| 489 | <dt> |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 490 | --shortstat |
| 491 | </dt> |
| 492 | <dd> |
| 493 | <p> |
| 494 | Output only the last line of the --stat format containing total |
| 495 | number of modified files, as well as number of added and deleted |
| 496 | lines. |
| 497 | </p> |
| 498 | </dd> |
| 499 | <dt> |
Junio C Hamano | 6a45be9 | 2008-04-22 08:19:03 | [diff] [blame] | 500 | --dirstat[=limit] |
| 501 | </dt> |
| 502 | <dd> |
| 503 | <p> |
Junio C Hamano | a2f4662 | 2008-09-03 05:20:31 | [diff] [blame] | 504 | Output the distribution of relative amount of changes (number of lines added or |
| 505 | removed) for each sub-directory. Directories with changes below |
| 506 | a cut-off percent (3% by default) are not shown. The cut-off percent |
| 507 | can be set with "--dirstat=limit". Changes in a child directory is not |
| 508 | counted for the parent directory, unless "--cumulative" is used. |
Junio C Hamano | 6a45be9 | 2008-04-22 08:19:03 | [diff] [blame] | 509 | </p> |
| 510 | </dd> |
| 511 | <dt> |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 512 | --dirstat-by-file[=limit] |
| 513 | </dt> |
| 514 | <dd> |
| 515 | <p> |
| 516 | Same as --dirstat, but counts changed files instead of lines. |
| 517 | </p> |
| 518 | </dd> |
| 519 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 520 | --summary |
| 521 | </dt> |
| 522 | <dd> |
| 523 | <p> |
| 524 | Output a condensed summary of extended header information |
| 525 | such as creations, renames and mode changes. |
| 526 | </p> |
| 527 | </dd> |
| 528 | <dt> |
| 529 | --patch-with-stat |
| 530 | </dt> |
| 531 | <dd> |
| 532 | <p> |
| 533 | Synonym for "-p --stat". |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 534 | |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 535 | </p> |
| 536 | </dd> |
| 537 | <dt> |
| 538 | -z |
| 539 | </dt> |
| 540 | <dd> |
| 541 | <p> |
Junio C Hamano | b968dbb | 2007-07-27 07:26:40 | [diff] [blame] | 542 | NUL-line termination on output. This affects the --raw |
| 543 | output field terminator. Also output from commands such |
| 544 | as "git-log" will be delimited with NUL between commits. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 545 | </p> |
| 546 | </dd> |
| 547 | <dt> |
| 548 | --name-only |
| 549 | </dt> |
| 550 | <dd> |
| 551 | <p> |
| 552 | Show only names of changed files. |
| 553 | </p> |
| 554 | </dd> |
| 555 | <dt> |
| 556 | --name-status |
| 557 | </dt> |
| 558 | <dd> |
| 559 | <p> |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 560 | Show only names and status of changed files. See the description |
| 561 | of the <tt>--diff-filter</tt> option on what the status letters mean. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 562 | </p> |
| 563 | </dd> |
| 564 | <dt> |
| 565 | --color |
| 566 | </dt> |
| 567 | <dd> |
| 568 | <p> |
| 569 | Show colored diff. |
| 570 | </p> |
| 571 | </dd> |
| 572 | <dt> |
| 573 | --no-color |
| 574 | </dt> |
| 575 | <dd> |
| 576 | <p> |
| 577 | Turn off colored diff, even when the configuration file |
| 578 | gives the default to color output. |
| 579 | </p> |
| 580 | </dd> |
| 581 | <dt> |
| 582 | --color-words |
| 583 | </dt> |
| 584 | <dd> |
| 585 | <p> |
| 586 | Show colored word diff, i.e. color words which have changed. |
| 587 | </p> |
| 588 | </dd> |
| 589 | <dt> |
| 590 | --no-renames |
| 591 | </dt> |
| 592 | <dd> |
| 593 | <p> |
| 594 | Turn off rename detection, even when the configuration |
| 595 | file gives the default to do so. |
| 596 | </p> |
| 597 | </dd> |
| 598 | <dt> |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 599 | --check |
| 600 | </dt> |
| 601 | <dd> |
| 602 | <p> |
| 603 | Warn if changes introduce trailing whitespace |
Junio C Hamano | 3dac504 | 2007-12-15 08:40:54 | [diff] [blame] | 604 | or an indent that uses a space before a tab. Exits with |
| 605 | non-zero status if problems are found. Not compatible with |
| 606 | --exit-code. |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 607 | </p> |
| 608 | </dd> |
| 609 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 610 | --full-index |
| 611 | </dt> |
| 612 | <dd> |
| 613 | <p> |
Junio C Hamano | 5cf43ca | 2008-08-20 09:14:14 | [diff] [blame] | 614 | Instead of the first handful of characters, show the full |
| 615 | pre- and post-image blob object names on the "index" |
| 616 | line when generating patch format output. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 617 | </p> |
| 618 | </dd> |
| 619 | <dt> |
| 620 | --binary |
| 621 | </dt> |
| 622 | <dd> |
| 623 | <p> |
| 624 | In addition to --full-index, output "binary diff" that |
| 625 | can be applied with "git apply". |
| 626 | </p> |
| 627 | </dd> |
| 628 | <dt> |
| 629 | --abbrev[=<n>] |
| 630 | </dt> |
| 631 | <dd> |
| 632 | <p> |
| 633 | Instead of showing the full 40-byte hexadecimal object |
| 634 | name in diff-raw format output and diff-tree header |
| 635 | lines, show only handful hexdigits prefix. This is |
| 636 | independent of --full-index option above, which controls |
| 637 | the diff-patch output format. Non default number of |
| 638 | digits can be specified with --abbrev=<n>. |
| 639 | </p> |
| 640 | </dd> |
| 641 | <dt> |
| 642 | -B |
| 643 | </dt> |
| 644 | <dd> |
| 645 | <p> |
| 646 | Break complete rewrite changes into pairs of delete and create. |
| 647 | </p> |
| 648 | </dd> |
| 649 | <dt> |
| 650 | -M |
| 651 | </dt> |
| 652 | <dd> |
| 653 | <p> |
| 654 | Detect renames. |
| 655 | </p> |
| 656 | </dd> |
| 657 | <dt> |
| 658 | -C |
| 659 | </dt> |
| 660 | <dd> |
| 661 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 662 | Detect copies as well as renames. See also <tt>--find-copies-harder</tt>. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 663 | </p> |
| 664 | </dd> |
| 665 | <dt> |
| 666 | --diff-filter=[ACDMRTUXB*] |
| 667 | </dt> |
| 668 | <dd> |
| 669 | <p> |
| 670 | Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>), |
| 671 | Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their |
Junio C Hamano | a2deec5 | 2008-10-18 18:58:09 | [diff] [blame] | 672 | type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>), |
| 673 | are Unmerged (<tt>U</tt>), are |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 674 | Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>). |
| 675 | Any combination of the filter characters may be used. |
| 676 | When <tt>*</tt> (All-or-none) is added to the combination, all |
| 677 | paths are selected if there is any file that matches |
| 678 | other criteria in the comparison; if there is no file |
| 679 | that matches other criteria, nothing is selected. |
| 680 | </p> |
| 681 | </dd> |
| 682 | <dt> |
| 683 | --find-copies-harder |
| 684 | </dt> |
| 685 | <dd> |
| 686 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 687 | For performance reasons, by default, <tt>-C</tt> option finds copies only |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 688 | if the original file of the copy was modified in the same |
| 689 | changeset. This flag makes the command |
| 690 | inspect unmodified files as candidates for the source of |
| 691 | copy. This is a very expensive operation for large |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 692 | projects, so use it with caution. Giving more than one |
| 693 | <tt>-C</tt> option has the same effect. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 694 | </p> |
| 695 | </dd> |
| 696 | <dt> |
| 697 | -l<num> |
| 698 | </dt> |
| 699 | <dd> |
| 700 | <p> |
| 701 | -M and -C options require O(n^2) processing time where n |
| 702 | is the number of potential rename/copy targets. This |
| 703 | option prevents rename/copy detection from running if |
| 704 | the number of rename/copy targets exceeds the specified |
| 705 | number. |
| 706 | </p> |
| 707 | </dd> |
| 708 | <dt> |
| 709 | -S<string> |
| 710 | </dt> |
| 711 | <dd> |
| 712 | <p> |
| 713 | Look for differences that contain the change in <string>. |
| 714 | </p> |
| 715 | </dd> |
| 716 | <dt> |
| 717 | --pickaxe-all |
| 718 | </dt> |
| 719 | <dd> |
| 720 | <p> |
| 721 | When -S finds a change, show all the changes in that |
| 722 | changeset, not just the files that contain the change |
| 723 | in <string>. |
| 724 | </p> |
| 725 | </dd> |
| 726 | <dt> |
| 727 | --pickaxe-regex |
| 728 | </dt> |
| 729 | <dd> |
| 730 | <p> |
| 731 | Make the <string> not a plain string but an extended POSIX |
| 732 | regex to match. |
| 733 | </p> |
| 734 | </dd> |
| 735 | <dt> |
| 736 | -O<orderfile> |
| 737 | </dt> |
| 738 | <dd> |
| 739 | <p> |
| 740 | Output the patch in the order specified in the |
| 741 | <orderfile>, which has one shell glob pattern per line. |
| 742 | </p> |
| 743 | </dd> |
| 744 | <dt> |
| 745 | -R |
| 746 | </dt> |
| 747 | <dd> |
| 748 | <p> |
| 749 | Swap two inputs; that is, show differences from index or |
| 750 | on-disk file to tree contents. |
| 751 | </p> |
| 752 | </dd> |
| 753 | <dt> |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 754 | --relative[=<path>] |
| 755 | </dt> |
| 756 | <dd> |
| 757 | <p> |
| 758 | When run from a subdirectory of the project, it can be |
| 759 | told to exclude changes outside the directory and show |
| 760 | pathnames relative to it with this option. When you are |
| 761 | not in a subdirectory (e.g. in a bare repository), you |
| 762 | can name which subdirectory to make the output relative |
| 763 | to by giving a <path> as an argument. |
| 764 | </p> |
| 765 | </dd> |
| 766 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 767 | --text |
| 768 | </dt> |
| 769 | <dd> |
| 770 | <p> |
| 771 | Treat all files as text. |
| 772 | </p> |
| 773 | </dd> |
| 774 | <dt> |
| 775 | -a |
| 776 | </dt> |
| 777 | <dd> |
| 778 | <p> |
| 779 | Shorthand for "--text". |
| 780 | </p> |
| 781 | </dd> |
| 782 | <dt> |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 783 | --ignore-space-at-eol |
| 784 | </dt> |
| 785 | <dd> |
| 786 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 787 | Ignore changes in whitespace at EOL. |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 788 | </p> |
| 789 | </dd> |
| 790 | <dt> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 791 | --ignore-space-change |
| 792 | </dt> |
| 793 | <dd> |
| 794 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 795 | Ignore changes in amount of whitespace. This ignores whitespace |
| 796 | at line end, and considers all other sequences of one or |
| 797 | more whitespace characters to be equivalent. |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 798 | </p> |
| 799 | </dd> |
| 800 | <dt> |
| 801 | -b |
| 802 | </dt> |
| 803 | <dd> |
| 804 | <p> |
| 805 | Shorthand for "--ignore-space-change". |
| 806 | </p> |
| 807 | </dd> |
| 808 | <dt> |
| 809 | --ignore-all-space |
| 810 | </dt> |
| 811 | <dd> |
| 812 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 813 | Ignore whitespace when comparing lines. This ignores |
| 814 | differences even if one line has whitespace where the other |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 815 | line has none. |
| 816 | </p> |
| 817 | </dd> |
| 818 | <dt> |
| 819 | -w |
| 820 | </dt> |
| 821 | <dd> |
| 822 | <p> |
| 823 | Shorthand for "--ignore-all-space". |
| 824 | </p> |
| 825 | </dd> |
Junio C Hamano | 48fd2f6 | 2007-03-19 02:02:30 | [diff] [blame] | 826 | <dt> |
| 827 | --exit-code |
| 828 | </dt> |
| 829 | <dd> |
| 830 | <p> |
| 831 | Make the program exit with codes similar to diff(1). |
| 832 | That is, it exits with 1 if there were differences and |
| 833 | 0 means no differences. |
| 834 | </p> |
| 835 | </dd> |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 836 | <dt> |
| 837 | --quiet |
| 838 | </dt> |
| 839 | <dd> |
| 840 | <p> |
| 841 | Disable all output of the program. Implies --exit-code. |
| 842 | </p> |
| 843 | </dd> |
Junio C Hamano | bb0f404 | 2007-07-04 06:41:40 | [diff] [blame] | 844 | <dt> |
| 845 | --ext-diff |
| 846 | </dt> |
| 847 | <dd> |
| 848 | <p> |
| 849 | Allow an external diff helper to be executed. If you set an |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 850 | external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need |
| 851 | to use this option with <a href="git-log.html">git-log(1)</a> and friends. |
Junio C Hamano | bb0f404 | 2007-07-04 06:41:40 | [diff] [blame] | 852 | </p> |
| 853 | </dd> |
| 854 | <dt> |
| 855 | --no-ext-diff |
| 856 | </dt> |
| 857 | <dd> |
| 858 | <p> |
| 859 | Disallow external diff drivers. |
| 860 | </p> |
| 861 | </dd> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 862 | <dt> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 863 | --ignore-submodules |
| 864 | </dt> |
| 865 | <dd> |
| 866 | <p> |
| 867 | Ignore changes to submodules in the diff generation. |
| 868 | </p> |
| 869 | </dd> |
| 870 | <dt> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 871 | --src-prefix=<prefix> |
| 872 | </dt> |
| 873 | <dd> |
| 874 | <p> |
| 875 | Show the given source prefix instead of "a/". |
| 876 | </p> |
| 877 | </dd> |
| 878 | <dt> |
| 879 | --dst-prefix=<prefix> |
| 880 | </dt> |
| 881 | <dd> |
| 882 | <p> |
| 883 | Show the given destination prefix instead of "b/". |
| 884 | </p> |
| 885 | </dd> |
| 886 | <dt> |
| 887 | --no-prefix |
| 888 | </dt> |
| 889 | <dd> |
| 890 | <p> |
| 891 | Do not show any source or destination prefix. |
| 892 | </p> |
| 893 | </dd> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 894 | </dl></div> |
| 895 | <div class="para"><p>For more detailed explanation on these common options, see also |
| 896 | <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div> |
| 897 | <div class="vlist"><dl> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 898 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 899 | <path>… |
| 900 | </dt> |
| 901 | <dd> |
| 902 | <p> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 903 | The <paths> parameters, when given, are used to limit |
| 904 | the diff to the named paths (you can give directory |
| 905 | names and get diff for all files under them). |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 906 | </p> |
| 907 | </dd> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 908 | </dl></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 909 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 910 | <h2 id="_output_format">Output format</h2> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 911 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 912 | <div class="para"><p>The output format from "git-diff-index", "git-diff-tree", |
| 913 | "git-diff-files" and "git diff --raw" are very similar.</p></div> |
| 914 | <div class="para"><p>These commands all compare two sets of things; what is |
| 915 | compared differs:</p></div> |
| 916 | <div class="vlist"><dl> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 917 | <dt> |
| 918 | git-diff-index <tree-ish> |
| 919 | </dt> |
| 920 | <dd> |
| 921 | <p> |
| 922 | compares the <tree-ish> and the files on the filesystem. |
| 923 | </p> |
| 924 | </dd> |
| 925 | <dt> |
| 926 | git-diff-index --cached <tree-ish> |
| 927 | </dt> |
| 928 | <dd> |
| 929 | <p> |
| 930 | compares the <tree-ish> and the index. |
| 931 | </p> |
| 932 | </dd> |
| 933 | <dt> |
| 934 | git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] |
| 935 | </dt> |
| 936 | <dd> |
| 937 | <p> |
| 938 | compares the trees named by the two arguments. |
| 939 | </p> |
| 940 | </dd> |
| 941 | <dt> |
| 942 | git-diff-files [<pattern>…] |
| 943 | </dt> |
| 944 | <dd> |
| 945 | <p> |
| 946 | compares the index and the files on the filesystem. |
| 947 | </p> |
| 948 | </dd> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 949 | </dl></div> |
| 950 | <div class="para"><p>An output line is formatted this way:</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 951 | <div class="listingblock"> |
| 952 | <div class="content"> |
| 953 | <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0 |
| 954 | copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2 |
| 955 | rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3 |
| 956 | create :000000 100644 0000000... 1234567... A file4 |
| 957 | delete :100644 000000 1234567... 0000000... D file5 |
| 958 | unmerged :000000 000000 0000000... 0000000... U file6</tt></pre> |
| 959 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 960 | <div class="para"><p>That is, from the left to the right:</p></div> |
| 961 | <div class="olist"><ol> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 962 | <li> |
| 963 | <p> |
| 964 | a colon. |
| 965 | </p> |
| 966 | </li> |
| 967 | <li> |
| 968 | <p> |
| 969 | mode for "src"; 000000 if creation or unmerged. |
| 970 | </p> |
| 971 | </li> |
| 972 | <li> |
| 973 | <p> |
| 974 | a space. |
| 975 | </p> |
| 976 | </li> |
| 977 | <li> |
| 978 | <p> |
| 979 | mode for "dst"; 000000 if deletion or unmerged. |
| 980 | </p> |
| 981 | </li> |
| 982 | <li> |
| 983 | <p> |
| 984 | a space. |
| 985 | </p> |
| 986 | </li> |
| 987 | <li> |
| 988 | <p> |
| 989 | sha1 for "src"; 0{40} if creation or unmerged. |
| 990 | </p> |
| 991 | </li> |
| 992 | <li> |
| 993 | <p> |
| 994 | a space. |
| 995 | </p> |
| 996 | </li> |
| 997 | <li> |
| 998 | <p> |
| 999 | sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree". |
| 1000 | </p> |
| 1001 | </li> |
| 1002 | <li> |
| 1003 | <p> |
| 1004 | a space. |
| 1005 | </p> |
| 1006 | </li> |
| 1007 | <li> |
| 1008 | <p> |
| 1009 | status, followed by optional "score" number. |
| 1010 | </p> |
| 1011 | </li> |
| 1012 | <li> |
| 1013 | <p> |
| 1014 | a tab or a NUL when <em>-z</em> option is used. |
| 1015 | </p> |
| 1016 | </li> |
| 1017 | <li> |
| 1018 | <p> |
| 1019 | path for "src" |
| 1020 | </p> |
| 1021 | </li> |
| 1022 | <li> |
| 1023 | <p> |
| 1024 | a tab or a NUL when <em>-z</em> option is used; only exists for C or R. |
| 1025 | </p> |
| 1026 | </li> |
| 1027 | <li> |
| 1028 | <p> |
| 1029 | path for "dst"; only exists for C or R. |
| 1030 | </p> |
| 1031 | </li> |
| 1032 | <li> |
| 1033 | <p> |
| 1034 | an LF or a NUL when <em>-z</em> option is used, to terminate the record. |
| 1035 | </p> |
| 1036 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1037 | </ol></div> |
Junio C Hamano | aa17c7c | 2008-11-03 04:36:58 | [diff] [blame] | 1038 | <div class="para"><p>Possible status letters are:</p></div> |
| 1039 | <div class="ilist"><ul> |
| 1040 | <li> |
| 1041 | <p> |
| 1042 | A: addition of a file |
| 1043 | </p> |
| 1044 | </li> |
| 1045 | <li> |
| 1046 | <p> |
| 1047 | C: copy of a file into a new one |
| 1048 | </p> |
| 1049 | </li> |
| 1050 | <li> |
| 1051 | <p> |
| 1052 | D: deletion of a file |
| 1053 | </p> |
| 1054 | </li> |
| 1055 | <li> |
| 1056 | <p> |
| 1057 | M: modification of the contents or mode of a file |
| 1058 | </p> |
| 1059 | </li> |
| 1060 | <li> |
| 1061 | <p> |
| 1062 | R: renaming of a file |
| 1063 | </p> |
| 1064 | </li> |
| 1065 | <li> |
| 1066 | <p> |
| 1067 | T: change in the type of the file |
| 1068 | </p> |
| 1069 | </li> |
| 1070 | <li> |
| 1071 | <p> |
| 1072 | U: file is unmerged (you must complete the merge before it can |
| 1073 | be committed) |
| 1074 | </p> |
| 1075 | </li> |
| 1076 | <li> |
| 1077 | <p> |
| 1078 | X: "unknown" change type (most probably a bug, please report it) |
| 1079 | </p> |
| 1080 | </li> |
| 1081 | </ul></div> |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame^] | 1082 | <div class="para"><p>Status letters C and R are always followed by a score (denoting the |
Junio C Hamano | aa17c7c | 2008-11-03 04:36:58 | [diff] [blame] | 1083 | percentage of similarity between the source and target of the move or |
| 1084 | copy), and are the only ones to be so.</p></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1085 | <div class="para"><p><sha1> is shown as all 0's if a file is new on the filesystem |
| 1086 | and it is out of sync with the index.</p></div> |
| 1087 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1088 | <div class="listingblock"> |
| 1089 | <div class="content"> |
| 1090 | <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre> |
| 1091 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1092 | <div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1093 | in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>, |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1094 | respectively.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1095 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1096 | <h2 id="_diff_format_for_merges">diff format for merges</h2> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1097 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1098 | <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw" |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1099 | can take <em>-c</em> or <em>--cc</em> option |
| 1100 | to generate diff output also for merge commits. The output differs |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1101 | from the format described above in the following way:</p></div> |
| 1102 | <div class="olist"><ol> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1103 | <li> |
| 1104 | <p> |
| 1105 | there is a colon for each parent |
| 1106 | </p> |
| 1107 | </li> |
| 1108 | <li> |
| 1109 | <p> |
| 1110 | there are more "src" modes and "src" sha1 |
| 1111 | </p> |
| 1112 | </li> |
| 1113 | <li> |
| 1114 | <p> |
| 1115 | status is concatenated status characters for each parent |
| 1116 | </p> |
| 1117 | </li> |
| 1118 | <li> |
| 1119 | <p> |
| 1120 | no optional "score" number |
| 1121 | </p> |
| 1122 | </li> |
| 1123 | <li> |
| 1124 | <p> |
| 1125 | single path, only for "dst" |
| 1126 | </p> |
| 1127 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1128 | </ol></div> |
| 1129 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1130 | <div class="listingblock"> |
| 1131 | <div class="content"> |
| 1132 | <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre> |
| 1133 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1134 | <div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from |
| 1135 | all parents.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1136 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1137 | <h2 id="_generating_patches_with_p">Generating patches with -p</h2> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1138 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1139 | <div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run |
Junio C Hamano | 00b8b63 | 2007-12-07 09:50:49 | [diff] [blame] | 1140 | with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or |
| 1141 | "git log" with the "-p" option, they |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1142 | do not produce the output described above; instead they produce a |
| 1143 | patch file. You can customize the creation of such patches via the |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1144 | GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div> |
| 1145 | <div class="para"><p>What the -p option produces is slightly different from the traditional |
| 1146 | diff format.</p></div> |
| 1147 | <div class="olist"><ol> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1148 | <li> |
| 1149 | <p> |
| 1150 | It is preceded with a "git diff" header, that looks like |
| 1151 | this: |
| 1152 | </p> |
| 1153 | <div class="literalblock"> |
| 1154 | <div class="content"> |
| 1155 | <pre><tt>diff --git a/file1 b/file2</tt></pre> |
| 1156 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1157 | <div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1158 | involved. Especially, even for a creation or a deletion, |
Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 1159 | <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1160 | <div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1161 | name of the source file of the rename/copy and the name of |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1162 | the file that rename/copy produces, respectively.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1163 | </li> |
| 1164 | <li> |
| 1165 | <p> |
| 1166 | It is followed by one or more extended header lines: |
| 1167 | </p> |
| 1168 | <div class="literalblock"> |
| 1169 | <div class="content"> |
| 1170 | <pre><tt>old mode <mode> |
| 1171 | new mode <mode> |
| 1172 | deleted file mode <mode> |
| 1173 | new file mode <mode> |
| 1174 | copy from <path> |
| 1175 | copy to <path> |
| 1176 | rename from <path> |
| 1177 | rename to <path> |
| 1178 | similarity index <number> |
| 1179 | dissimilarity index <number> |
| 1180 | index <hash>..<hash> <mode></tt></pre> |
| 1181 | </div></div> |
| 1182 | </li> |
| 1183 | <li> |
| 1184 | <p> |
| 1185 | TAB, LF, double quote and backslash characters in pathnames |
| 1186 | are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively. |
| 1187 | If there is need for such substitution then the whole |
| 1188 | pathname is put in double quotes. |
| 1189 | </p> |
| 1190 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1191 | </ol></div> |
| 1192 | <div class="para"><p>The similarity index is the percentage of unchanged lines, and |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1193 | the dissimilarity index is the percentage of changed lines. It |
| 1194 | is a rounded down integer, followed by a percent sign. The |
| 1195 | similarity index value of 100% is thus reserved for two equal |
| 1196 | files, while 100% dissimilarity means that no line from the old |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1197 | file made it into the new one.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1198 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1199 | <h2 id="_combined_diff_format">combined diff format</h2> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1200 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1201 | <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or |
Junio C Hamano | 00b8b63 | 2007-12-07 09:50:49 | [diff] [blame] | 1202 | <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit |
| 1203 | with "git log -p", this is the default format. |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1204 | A <em>combined diff</em> format looks like this:</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1205 | <div class="listingblock"> |
| 1206 | <div class="content"> |
| 1207 | <pre><tt>diff --combined describe.c |
| 1208 | index fabadb8,cc95eb0..4866510 |
| 1209 | --- a/describe.c |
| 1210 | +++ b/describe.c |
| 1211 | @@@ -98,20 -98,12 +98,20 @@@ |
| 1212 | return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; |
| 1213 | } |
| 1214 | |
| 1215 | - static void describe(char *arg) |
| 1216 | -static void describe(struct commit *cmit, int last_one) |
| 1217 | ++static void describe(char *arg, int last_one) |
| 1218 | { |
| 1219 | + unsigned char sha1[20]; |
| 1220 | + struct commit *cmit; |
| 1221 | struct commit_list *list; |
| 1222 | static int initialized = 0; |
| 1223 | struct commit_name *n; |
| 1224 | |
| 1225 | + if (get_sha1(arg, sha1) < 0) |
| 1226 | + usage(describe_usage); |
| 1227 | + cmit = lookup_commit_reference(sha1); |
| 1228 | + if (!cmit) |
| 1229 | + usage(describe_usage); |
| 1230 | + |
| 1231 | if (!initialized) { |
| 1232 | initialized = 1; |
| 1233 | for_each_ref(get_name);</tt></pre> |
| 1234 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1235 | <div class="olist"><ol> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1236 | <li> |
| 1237 | <p> |
| 1238 | It is preceded with a "git diff" header, that looks like |
| 1239 | this (when <em>-c</em> option is used): |
| 1240 | </p> |
| 1241 | <div class="literalblock"> |
| 1242 | <div class="content"> |
| 1243 | <pre><tt>diff --combined file</tt></pre> |
| 1244 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1245 | <div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1246 | <div class="literalblock"> |
| 1247 | <div class="content"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1248 | <pre><tt>diff --cc file</tt></pre> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1249 | </div></div> |
| 1250 | </li> |
| 1251 | <li> |
| 1252 | <p> |
| 1253 | It is followed by one or more extended header lines |
| 1254 | (this example shows a merge with two parents): |
| 1255 | </p> |
| 1256 | <div class="literalblock"> |
| 1257 | <div class="content"> |
| 1258 | <pre><tt>index <hash>,<hash>..<hash> |
| 1259 | mode <mode>,<mode>..<mode> |
| 1260 | new file mode <mode> |
| 1261 | deleted file mode <mode>,<mode></tt></pre> |
| 1262 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1263 | <div class="para"><p>The <tt>mode <mode>,<mode>..<mode></tt> line appears only if at least one of |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1264 | the <mode> is different from the rest. Extended headers with |
| 1265 | information about detected contents movement (renames and |
| 1266 | copying detection) are designed to work with diff of two |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1267 | <tree-ish> and are not used by combined diff format.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1268 | </li> |
| 1269 | <li> |
| 1270 | <p> |
| 1271 | It is followed by two-line from-file/to-file header |
| 1272 | </p> |
| 1273 | <div class="literalblock"> |
| 1274 | <div class="content"> |
| 1275 | <pre><tt>--- a/file |
| 1276 | +++ b/file</tt></pre> |
| 1277 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1278 | <div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1279 | format, <tt>/dev/null</tt> is used to signal created or deleted |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1280 | files.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1281 | </li> |
| 1282 | <li> |
| 1283 | <p> |
| 1284 | Chunk header format is modified to prevent people from |
| 1285 | accidentally feeding it to <tt>patch -p1</tt>. Combined diff format |
| 1286 | was created for review of merge commit changes, and was not |
| 1287 | meant for apply. The change is similar to the change in the |
| 1288 | extended <em>index</em> header: |
| 1289 | </p> |
| 1290 | <div class="literalblock"> |
| 1291 | <div class="content"> |
| 1292 | <pre><tt>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</tt></pre> |
| 1293 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1294 | <div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk |
| 1295 | header for combined diff format.</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1296 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1297 | </ol></div> |
| 1298 | <div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1299 | files A and B with a single column that has <tt>-</tt> (minus — |
| 1300 | appears in A but removed in B), <tt>+</tt> (plus — missing in A but |
| 1301 | added to B), or <tt>" "</tt> (space — unchanged) prefix, this format |
| 1302 | compares two or more files file1, file2,… with one file X, and |
| 1303 | shows how X differs from each of fileN. One column for each of |
| 1304 | fileN is prepended to the output line to note how X's line is |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1305 | different from it.</p></div> |
| 1306 | <div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1307 | fileN but it does not appear in the result. A <tt>+</tt> character |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame^] | 1308 | in the column N means that the line appears in the result, |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1309 | and fileN does not have that line (in other words, the line was |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1310 | added, from the point of view of that parent).</p></div> |
| 1311 | <div class="para"><p>In the above example output, the function signature was changed |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1312 | from both files (hence two <tt>-</tt> removals from both file1 and |
Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 1313 | file2, plus <tt>++</tt> to mean one line that was added does not appear |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame^] | 1314 | in either file1 nor file2). Also eight other lines are the same |
| 1315 | from file1 but do not appear in file2 (hence prefixed with <tt>+</tt>).</p></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1316 | <div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1317 | merge commit with the merge result (i.e. file1..fileN are the |
| 1318 | parents). When shown by <tt>git diff-files -c</tt>, it compares the |
| 1319 | two unresolved merge parents with the working tree file |
| 1320 | (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1321 | "their version").</p></div> |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1322 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1323 | <h2 id="_other_diff_formats">other diff formats</h2> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1324 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1325 | <div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1326 | copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the |
| 1327 | output. These options can be combined with other options, such as |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1328 | <tt>-p</tt>, and are meant for human consumption.</p></div> |
| 1329 | <div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1330 | formats the pathnames compactly by combining common prefix and suffix of |
| 1331 | the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1332 | <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1333 | <div class="listingblock"> |
| 1334 | <div class="content"> |
| 1335 | <pre><tt>arch/{i386 => x86}/Makefile | 4 +--</tt></pre> |
| 1336 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1337 | <div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1338 | for easier machine consumption. An entry in <tt>--numstat</tt> output looks |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1339 | like this:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1340 | <div class="listingblock"> |
| 1341 | <div class="content"> |
| 1342 | <pre><tt>1 2 README |
| 1343 | 3 1 arch/{i386 => x86}/Makefile</tt></pre> |
| 1344 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1345 | <div class="para"><p>That is, from left to right:</p></div> |
| 1346 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1347 | <li> |
| 1348 | <p> |
| 1349 | the number of added lines; |
| 1350 | </p> |
| 1351 | </li> |
| 1352 | <li> |
| 1353 | <p> |
| 1354 | a tab; |
| 1355 | </p> |
| 1356 | </li> |
| 1357 | <li> |
| 1358 | <p> |
| 1359 | the number of deleted lines; |
| 1360 | </p> |
| 1361 | </li> |
| 1362 | <li> |
| 1363 | <p> |
| 1364 | a tab; |
| 1365 | </p> |
| 1366 | </li> |
| 1367 | <li> |
| 1368 | <p> |
| 1369 | pathname (possibly with rename/copy information); |
| 1370 | </p> |
| 1371 | </li> |
| 1372 | <li> |
| 1373 | <p> |
| 1374 | a newline. |
| 1375 | </p> |
| 1376 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1377 | </ol></div> |
| 1378 | <div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1379 | <div class="listingblock"> |
| 1380 | <div class="content"> |
| 1381 | <pre><tt>1 2 README NUL |
| 1382 | 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre> |
| 1383 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1384 | <div class="para"><p>That is:</p></div> |
| 1385 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1386 | <li> |
| 1387 | <p> |
| 1388 | the number of added lines; |
| 1389 | </p> |
| 1390 | </li> |
| 1391 | <li> |
| 1392 | <p> |
| 1393 | a tab; |
| 1394 | </p> |
| 1395 | </li> |
| 1396 | <li> |
| 1397 | <p> |
| 1398 | the number of deleted lines; |
| 1399 | </p> |
| 1400 | </li> |
| 1401 | <li> |
| 1402 | <p> |
| 1403 | a tab; |
| 1404 | </p> |
| 1405 | </li> |
| 1406 | <li> |
| 1407 | <p> |
| 1408 | a NUL (only exists if renamed/copied); |
| 1409 | </p> |
| 1410 | </li> |
| 1411 | <li> |
| 1412 | <p> |
| 1413 | pathname in preimage; |
| 1414 | </p> |
| 1415 | </li> |
| 1416 | <li> |
| 1417 | <p> |
| 1418 | a NUL (only exists if renamed/copied); |
| 1419 | </p> |
| 1420 | </li> |
| 1421 | <li> |
| 1422 | <p> |
| 1423 | pathname in postimage (only exists if renamed/copied); |
| 1424 | </p> |
| 1425 | </li> |
| 1426 | <li> |
| 1427 | <p> |
| 1428 | a NUL. |
| 1429 | </p> |
| 1430 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1431 | </ol></div> |
| 1432 | <div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1433 | scripts that read the output to tell if the current record being read is |
| 1434 | a single-path record or a rename/copy record without reading ahead. |
| 1435 | After reading added and deleted lines, reading up to <tt>NUL</tt> would yield |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1436 | the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1437 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1438 | <h2 id="_examples">EXAMPLES</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1439 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1440 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1441 | <dt> |
| 1442 | Various ways to check your working tree |
| 1443 | </dt> |
| 1444 | <dd> |
| 1445 | <div class="listingblock"> |
| 1446 | <div class="content"> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1447 | <pre><tt>$ git diff <b>(1)</b> |
Junio C Hamano | 47848ae | 2006-12-14 11:20:06 | [diff] [blame] | 1448 | $ git diff --cached <b>(2)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1449 | $ git diff HEAD <b>(3)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1450 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1451 | <div class="colist"><ol> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1452 | <li> |
| 1453 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1454 | Changes in the working tree not yet staged for the next commit. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1455 | </p> |
| 1456 | </li> |
| 1457 | <li> |
| 1458 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1459 | Changes between the index and your last commit; what you |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1460 | would be committing if you run "git commit" without "-a" option. |
| 1461 | </p> |
| 1462 | </li> |
| 1463 | <li> |
| 1464 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1465 | Changes in the working tree since your last commit; what you |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1466 | would be committing if you run "git commit -a" |
| 1467 | </p> |
| 1468 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1469 | </ol></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1470 | </dd> |
| 1471 | <dt> |
| 1472 | Comparing with arbitrary commits |
| 1473 | </dt> |
| 1474 | <dd> |
| 1475 | <div class="listingblock"> |
| 1476 | <div class="content"> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1477 | <pre><tt>$ git diff test <b>(1)</b> |
| 1478 | $ git diff HEAD -- ./test <b>(2)</b> |
| 1479 | $ git diff HEAD^ HEAD <b>(3)</b></tt></pre> |
| 1480 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1481 | <div class="colist"><ol> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1482 | <li> |
| 1483 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1484 | Instead of using the tip of the current branch, compare with the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1485 | tip of "test" branch. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1486 | </p> |
| 1487 | </li> |
| 1488 | <li> |
| 1489 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1490 | Instead of comparing with the tip of "test" branch, compare with |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 1491 | the tip of the current branch, but limit the comparison to the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1492 | file "test". |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1493 | </p> |
| 1494 | </li> |
| 1495 | <li> |
| 1496 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1497 | Compare the version before the last commit and the last commit. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1498 | </p> |
| 1499 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1500 | </ol></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1501 | </dd> |
| 1502 | <dt> |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 1503 | Comparing branches |
| 1504 | </dt> |
| 1505 | <dd> |
| 1506 | <div class="listingblock"> |
| 1507 | <div class="content"> |
| 1508 | <pre><tt>$ git diff topic master <b>(1)</b> |
| 1509 | $ git diff topic..master <b>(2)</b> |
| 1510 | $ git diff topic...master <b>(3)</b></tt></pre> |
| 1511 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1512 | <div class="colist"><ol> |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 1513 | <li> |
| 1514 | <p> |
| 1515 | Changes between the tips of the topic and the master branches. |
| 1516 | </p> |
| 1517 | </li> |
| 1518 | <li> |
| 1519 | <p> |
| 1520 | Same as above. |
| 1521 | </p> |
| 1522 | </li> |
| 1523 | <li> |
| 1524 | <p> |
Junio C Hamano | 764a667 | 2007-10-23 01:23:31 | [diff] [blame] | 1525 | Changes that occurred on the master branch since when the topic |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 1526 | branch was started off it. |
| 1527 | </p> |
| 1528 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1529 | </ol></div> |
Junio C Hamano | c435b1c | 2007-08-28 06:25:35 | [diff] [blame] | 1530 | </dd> |
| 1531 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1532 | Limiting the diff output |
| 1533 | </dt> |
| 1534 | <dd> |
| 1535 | <div class="listingblock"> |
| 1536 | <div class="content"> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1537 | <pre><tt>$ git diff --diff-filter=MRC <b>(1)</b> |
Junio C Hamano | bdeff82 | 2007-07-30 09:07:17 | [diff] [blame] | 1538 | $ git diff --name-status <b>(2)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1539 | $ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre> |
| 1540 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1541 | <div class="colist"><ol> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1542 | <li> |
| 1543 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1544 | Show only modification, rename and copy, but not addition |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1545 | nor deletion. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1546 | </p> |
| 1547 | </li> |
| 1548 | <li> |
| 1549 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1550 | Show only names and the nature of change, but not actual |
Junio C Hamano | bdeff82 | 2007-07-30 09:07:17 | [diff] [blame] | 1551 | diff output. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1552 | </p> |
| 1553 | </li> |
| 1554 | <li> |
| 1555 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1556 | Limit diff output to named subtrees. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1557 | </p> |
| 1558 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1559 | </ol></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1560 | </dd> |
| 1561 | <dt> |
| 1562 | Munging the diff output |
| 1563 | </dt> |
| 1564 | <dd> |
| 1565 | <div class="listingblock"> |
| 1566 | <div class="content"> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1567 | <pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b> |
| 1568 | $ git diff -R <b>(2)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1569 | </div></div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1570 | <div class="colist"><ol> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1571 | <li> |
| 1572 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1573 | Spend extra cycles to find renames, copies and complete |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1574 | rewrites (very expensive). |
| 1575 | </p> |
| 1576 | </li> |
| 1577 | <li> |
| 1578 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 1579 | Output diff in reverse. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1580 | </p> |
| 1581 | </li> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1582 | </ol></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1583 | </dd> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1584 | </dl></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1585 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1586 | <h2 id="_author">Author</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1587 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1588 | <div class="para"><p>Written by Linus Torvalds <torvalds@osdl.org></p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1589 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1590 | <h2 id="_documentation">Documentation</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1591 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1592 | <div class="para"><p>Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1593 | </div> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1594 | <h2 id="_git">GIT</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1595 | <div class="sectionbody"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1596 | <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1597 | </div> |
| 1598 | <div id="footer"> |
| 1599 | <div id="footer-text"> |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame^] | 1600 | Last updated 2008-12-20 06:29:39 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1601 | </div> |
| 1602 | </div> |
| 1603 | </body> |
| 1604 | </html> |