Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [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-rerere(1)</title> |
| 260 | </head> |
| 261 | <body> |
| 262 | <div id="header"> |
| 263 | <h1> |
| 264 | git-rerere(1) Manual Page |
| 265 | </h1> |
| 266 | <h2>NAME</h2> |
| 267 | <div class="sectionbody"> |
| 268 | <p>git-rerere - |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 269 | Reuse recorded resolution of conflicted merges |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 270 | </p> |
| 271 | </div> |
| 272 | </div> |
| 273 | <h2>SYNOPSIS</h2> |
| 274 | <div class="sectionbody"> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 275 | <p><em>git-rerere</em> [clear|diff|status|gc]</p> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 276 | </div> |
| 277 | <h2>DESCRIPTION</h2> |
| 278 | <div class="sectionbody"> |
| 279 | <p>In a workflow that employs relatively long lived topic branches, |
| 280 | the developer sometimes needs to resolve the same conflict over |
| 281 | and over again until the topic branches are done (either merged |
| 282 | to the "release" branch, or sent out and accepted upstream).</p> |
| 283 | <p>This command helps this process by recording conflicted |
| 284 | automerge results and corresponding hand-resolve results on the |
| 285 | initial manual merge, and later by noticing the same automerge |
| 286 | results and applying the previously recorded hand resolution.</p> |
Junio C Hamano | 0e47b23 | 2008-01-15 08:31:10 | [diff] [blame] | 287 | <div class="admonitionblock"> |
| 288 | <table><tr> |
| 289 | <td class="icon"> |
| 290 | <div class="title">Note</div> |
| 291 | </td> |
| 292 | <td class="content">You need to set the configuration variable rerere.enabled to |
| 293 | enable this command.</td> |
| 294 | </tr></table> |
| 295 | </div> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 296 | </div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 297 | <h2>COMMANDS</h2> |
| 298 | <div class="sectionbody"> |
| 299 | <p>Normally, git-rerere is run without arguments or user-intervention. |
| 300 | However, it has several commands that allow it to interact with |
| 301 | its working state.</p> |
| 302 | <dl> |
| 303 | <dt> |
| 304 | <em>clear</em> |
| 305 | </dt> |
| 306 | <dd> |
| 307 | <p> |
| 308 | This resets the metadata used by rerere if a merge resolution is to be |
| 309 | is aborted. Calling <a href="git-am.html">git-am(1)</a> --skip or <a href="git-rebase.html">git-rebase(1)</a> |
Junio C Hamano | f9771f6 | 2007-01-17 17:42:30 | [diff] [blame] | 310 | [--skip|--abort] will automatically invoke this command. |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 311 | </p> |
| 312 | </dd> |
| 313 | <dt> |
| 314 | <em>diff</em> |
| 315 | </dt> |
| 316 | <dd> |
| 317 | <p> |
| 318 | This displays diffs for the current state of the resolution. It is |
| 319 | useful for tracking what has changed while the user is resolving |
| 320 | conflicts. Additional arguments are passed directly to the system |
| 321 | diff(1) command installed in PATH. |
| 322 | </p> |
| 323 | </dd> |
| 324 | <dt> |
| 325 | <em>status</em> |
| 326 | </dt> |
| 327 | <dd> |
| 328 | <p> |
| 329 | Like diff, but this only prints the filenames that will be tracked |
| 330 | for resolutions. |
| 331 | </p> |
| 332 | </dd> |
| 333 | <dt> |
| 334 | <em>gc</em> |
| 335 | </dt> |
| 336 | <dd> |
| 337 | <p> |
| 338 | This command is used to prune records of conflicted merge that |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 339 | occurred long time ago. By default, conflicts older than 15 |
| 340 | days that you have not recorded their resolution, and conflicts |
| 341 | older than 60 days, are pruned. These are controlled with |
| 342 | <tt>gc.rerereunresolved</tt> and <tt>gc.rerereresolved</tt> configuration |
| 343 | variables. |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 344 | </p> |
| 345 | </dd> |
| 346 | </dl> |
| 347 | </div> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 348 | <h2>DISCUSSION</h2> |
| 349 | <div class="sectionbody"> |
| 350 | <p>When your topic branch modifies overlapping area that your |
| 351 | master branch (or upstream) touched since your topic branch |
| 352 | forked from it, you may want to test it with the latest master, |
| 353 | even before your topic branch is ready to be pushed upstream:</p> |
| 354 | <div class="listingblock"> |
| 355 | <div class="content"> |
| 356 | <pre><tt> o---*---o topic |
| 357 | / |
| 358 | o---o---o---*---o---o master</tt></pre> |
| 359 | </div></div> |
| 360 | <p>For such a test, you need to merge master and topic somehow. |
| 361 | One way to do it is to pull master into the topic branch:</p> |
| 362 | <div class="listingblock"> |
| 363 | <div class="content"> |
| 364 | <pre><tt> $ git checkout topic |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 365 | $ git merge master |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 366 | |
| 367 | o---*---o---+ topic |
| 368 | / / |
| 369 | o---o---o---*---o---o master</tt></pre> |
| 370 | </div></div> |
| 371 | <p>The commits marked with <tt>*</tt> touch the same area in the same |
| 372 | file; you need to resolve the conflicts when creating the commit |
| 373 | marked with <tt>+</tt>. Then you can test the result to make sure your |
| 374 | work-in-progress still works with what is in the latest master.</p> |
| 375 | <p>After this test merge, there are two ways to continue your work |
| 376 | on the topic. The easiest is to build on top of the test merge |
| 377 | commit <tt>+</tt>, and when your work in the topic branch is finally |
| 378 | ready, pull the topic branch into master, and/or ask the |
| 379 | upstream to pull from you. By that time, however, the master or |
| 380 | the upstream might have been advanced since the test merge <tt>+</tt>, |
| 381 | in which case the final commit graph would look like this:</p> |
| 382 | <div class="listingblock"> |
| 383 | <div class="content"> |
| 384 | <pre><tt> $ git checkout topic |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 385 | $ git merge master |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 386 | $ ... work on both topic and master branches |
| 387 | $ git checkout master |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 388 | $ git merge topic |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 389 | |
| 390 | o---*---o---+---o---o topic |
| 391 | / / \ |
| 392 | o---o---o---*---o---o---o---o---+ master</tt></pre> |
| 393 | </div></div> |
| 394 | <p>When your topic branch is long-lived, however, your topic branch |
| 395 | would end up having many such "Merge from master" commits on it, |
| 396 | which would unnecessarily clutter the development history. |
| 397 | Readers of the Linux kernel mailing list may remember that Linus |
| 398 | complained about such too frequent test merges when a subsystem |
| 399 | maintainer asked to pull from a branch full of "useless merges".</p> |
| 400 | <p>As an alternative, to keep the topic branch clean of test |
| 401 | merges, you could blow away the test merge, and keep building on |
| 402 | top of the tip before the test merge:</p> |
| 403 | <div class="listingblock"> |
| 404 | <div class="content"> |
| 405 | <pre><tt> $ git checkout topic |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 406 | $ git merge master |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 407 | $ git reset --hard HEAD^ ;# rewind the test merge |
| 408 | $ ... work on both topic and master branches |
| 409 | $ git checkout master |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 410 | $ git merge topic |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 411 | |
| 412 | o---*---o-------o---o topic |
| 413 | / \ |
| 414 | o---o---o---*---o---o---o---o---+ master</tt></pre> |
| 415 | </div></div> |
| 416 | <p>This would leave only one merge commit when your topic branch is |
| 417 | finally ready and merged into the master branch. This merge |
| 418 | would require you to resolve the conflict, introduced by the |
| 419 | commits marked with <tt>*</tt>. However, often this conflict is the |
| 420 | same conflict you resolved when you created the test merge you |
| 421 | blew away. <tt>git-rerere</tt> command helps you to resolve this final |
| 422 | conflicted merge using the information from your earlier hand |
| 423 | resolve.</p> |
| 424 | <p>Running <tt>git-rerere</tt> command immediately after a conflicted |
| 425 | automerge records the conflicted working tree files, with the |
| 426 | usual conflict markers <tt><<<<<<<</tt>, <tt>=======</tt>, and <tt>>>>>>>></tt> in |
| 427 | them. Later, after you are done resolving the conflicts, |
| 428 | running <tt>git-rerere</tt> again records the resolved state of these |
| 429 | files. Suppose you did this when you created the test merge of |
| 430 | master into the topic branch.</p> |
| 431 | <p>Next time, running <tt>git-rerere</tt> after seeing a conflicted |
| 432 | automerge, if the conflict is the same as the earlier one |
| 433 | recorded, it is noticed and a three-way merge between the |
| 434 | earlier conflicted automerge, the earlier manual resolution, and |
| 435 | the current conflicted automerge is performed by the command. |
| 436 | If this three-way merge resolves cleanly, the result is written |
| 437 | out to your working tree file, so you would not have to manually |
| 438 | resolve it. Note that <tt>git-rerere</tt> leaves the index file alone, |
| 439 | so you still need to do the final sanity checks with <tt>git diff</tt> |
Junio C Hamano | 89d4e0f | 2007-02-18 00:34:59 | [diff] [blame] | 440 | (or <tt>git diff -c</tt>) and <tt>git add</tt> when you are satisfied.</p> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 441 | <p>As a convenience measure, <tt>git-merge</tt> automatically invokes |
| 442 | <tt>git-rerere</tt> when it exits with a failed automerge, which |
| 443 | records it if it is a new conflict, or reuses the earlier hand |
| 444 | resolve when it is not. <tt>git-commit</tt> also invokes <tt>git-rerere</tt> |
| 445 | when recording a merge result. What this means is that you do |
| 446 | not have to do anything special yourself (Note: you still have |
Junio C Hamano | 7a4a283 | 2007-07-07 21:53:22 | [diff] [blame] | 447 | to set the config variable rerere.enabled to enable this command).</p> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 448 | <p>In our example, when you did the test merge, the manual |
| 449 | resolution is recorded, and it will be reused when you do the |
| 450 | actual merge later with updated master and topic branch, as long |
| 451 | as the earlier resolution is still applicable.</p> |
| 452 | <p>The information <tt>git-rerere</tt> records is also used when running |
| 453 | <tt>git-rebase</tt>. After blowing away the test merge and continuing |
| 454 | development on the topic branch:</p> |
| 455 | <div class="listingblock"> |
| 456 | <div class="content"> |
| 457 | <pre><tt> o---*---o-------o---o topic |
| 458 | / |
| 459 | o---o---o---*---o---o---o---o master |
| 460 | |
| 461 | $ git rebase master topic |
| 462 | |
| 463 | o---*---o-------o---o topic |
| 464 | / |
| 465 | o---o---o---*---o---o---o---o master</tt></pre> |
| 466 | </div></div> |
| 467 | <p>you could run <tt>git rebase master topic</tt>, to keep yourself |
| 468 | up-to-date even before your topic is ready to be sent upstream. |
| 469 | This would result in falling back to three-way merge, and it |
| 470 | would conflict the same way the test merge you resolved earlier. |
| 471 | <tt>git-rerere</tt> is run by <tt>git rebase</tt> to help you resolve this |
| 472 | conflict.</p> |
| 473 | </div> |
| 474 | <h2>Author</h2> |
| 475 | <div class="sectionbody"> |
| 476 | <p>Written by Junio C Hamano <junkio@cox.net></p> |
| 477 | </div> |
| 478 | <h2>GIT</h2> |
| 479 | <div class="sectionbody"> |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 480 | <p>Part of the <a href="git.html">git(1)</a> suite</p> |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 481 | </div> |
| 482 | <div id="footer"> |
| 483 | <div id="footer-text"> |
Junio C Hamano | e2b205c | 2008-06-08 01:43:44 | [diff] [blame] | 484 | Last updated 08-Jun-2008 01:34:06 UTC |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 485 | </div> |
| 486 | </div> |
| 487 | </body> |
| 488 | </html> |