blob: 136ec0c0dfe4a6aa1418fece48da870651ab72f8 [file] [log] [blame]
Junio C Hamano40f2f8d2006-02-07 08:04:391<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6<meta name="generator" content="AsciiDoc 7.0.2" />
7<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-rerere(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-rerere(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-rerere -
Junio C Hamano7c73c662007-01-19 00:37:50269 Reuse recorded resolution of conflicted merges
Junio C Hamano40f2f8d2006-02-07 08:04:39270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano74640642006-12-27 10:59:55275<p><em>git-rerere</em> [clear|diff|status|gc]</p>
Junio C Hamano40f2f8d2006-02-07 08:04:39276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
279<p>In a workflow that employs relatively long lived topic branches,
280the developer sometimes needs to resolve the same conflict over
281and over again until the topic branches are done (either merged
282to the "release" branch, or sent out and accepted upstream).</p>
283<p>This command helps this process by recording conflicted
284automerge results and corresponding hand-resolve results on the
285initial manual merge, and later by noticing the same automerge
286results and applying the previously recorded hand resolution.</p>
Junio C Hamano0e47b232008-01-15 08:31:10287<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
293enable this command.</td>
294</tr></table>
295</div>
Junio C Hamano40f2f8d2006-02-07 08:04:39296</div>
Junio C Hamanoe7935c42006-12-13 21:32:17297<h2>COMMANDS</h2>
298<div class="sectionbody">
299<p>Normally, git-rerere is run without arguments or user-intervention.
300However, it has several commands that allow it to interact with
301its working state.</p>
302<dl>
303<dt>
304<em>clear</em>
305</dt>
306<dd>
307<p>
308This resets the metadata used by rerere if a merge resolution is to be
309is aborted. Calling <a href="git-am.html">git-am(1)</a> --skip or <a href="git-rebase.html">git-rebase(1)</a>
Junio C Hamanof9771f62007-01-17 17:42:30310[--skip|--abort] will automatically invoke this command.
Junio C Hamanoe7935c42006-12-13 21:32:17311</p>
312</dd>
313<dt>
314<em>diff</em>
315</dt>
316<dd>
317<p>
318This displays diffs for the current state of the resolution. It is
319useful for tracking what has changed while the user is resolving
320conflicts. Additional arguments are passed directly to the system
321diff(1) command installed in PATH.
322</p>
323</dd>
324<dt>
325<em>status</em>
326</dt>
327<dd>
328<p>
329Like diff, but this only prints the filenames that will be tracked
330for resolutions.
331</p>
332</dd>
333<dt>
334<em>gc</em>
335</dt>
336<dd>
337<p>
338This command is used to prune records of conflicted merge that
Junio C Hamano74640642006-12-27 10:59:55339occurred long time ago. By default, conflicts older than 15
340days that you have not recorded their resolution, and conflicts
341older than 60 days, are pruned. These are controlled with
342<tt>gc.rerereunresolved</tt> and <tt>gc.rerereresolved</tt> configuration
343variables.
Junio C Hamanoe7935c42006-12-13 21:32:17344</p>
345</dd>
346</dl>
347</div>
Junio C Hamano40f2f8d2006-02-07 08:04:39348<h2>DISCUSSION</h2>
349<div class="sectionbody">
350<p>When your topic branch modifies overlapping area that your
351master branch (or upstream) touched since your topic branch
352forked from it, you may want to test it with the latest master,
353even 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.
361One 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 Hamanoedd2b0a2007-01-15 06:12:45365 $ git merge master
Junio C Hamano40f2f8d2006-02-07 08:04:39366
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
372file; you need to resolve the conflicts when creating the commit
373marked with <tt>+</tt>. Then you can test the result to make sure your
374work-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
376on the topic. The easiest is to build on top of the test merge
377commit <tt>+</tt>, and when your work in the topic branch is finally
378ready, pull the topic branch into master, and/or ask the
379upstream to pull from you. By that time, however, the master or
380the upstream might have been advanced since the test merge <tt>+</tt>,
381in 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 Hamanoedd2b0a2007-01-15 06:12:45385 $ git merge master
Junio C Hamano40f2f8d2006-02-07 08:04:39386 $ ... work on both topic and master branches
387 $ git checkout master
Junio C Hamanoedd2b0a2007-01-15 06:12:45388 $ git merge topic
Junio C Hamano40f2f8d2006-02-07 08:04:39389
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
395would end up having many such "Merge from master" commits on it,
396which would unnecessarily clutter the development history.
397Readers of the Linux kernel mailing list may remember that Linus
398complained about such too frequent test merges when a subsystem
399maintainer asked to pull from a branch full of "useless merges".</p>
400<p>As an alternative, to keep the topic branch clean of test
401merges, you could blow away the test merge, and keep building on
402top of the tip before the test merge:</p>
403<div class="listingblock">
404<div class="content">
405<pre><tt> $ git checkout topic
Junio C Hamanoedd2b0a2007-01-15 06:12:45406 $ git merge master
Junio C Hamano40f2f8d2006-02-07 08:04:39407 $ git reset --hard HEAD^ ;# rewind the test merge
408 $ ... work on both topic and master branches
409 $ git checkout master
Junio C Hamanoedd2b0a2007-01-15 06:12:45410 $ git merge topic
Junio C Hamano40f2f8d2006-02-07 08:04:39411
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
417finally ready and merged into the master branch. This merge
418would require you to resolve the conflict, introduced by the
419commits marked with <tt>*</tt>. However, often this conflict is the
420same conflict you resolved when you created the test merge you
421blew away. <tt>git-rerere</tt> command helps you to resolve this final
422conflicted merge using the information from your earlier hand
423resolve.</p>
424<p>Running <tt>git-rerere</tt> command immediately after a conflicted
425automerge records the conflicted working tree files, with the
426usual conflict markers <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>, <tt>=======</tt>, and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> in
427them. Later, after you are done resolving the conflicts,
428running <tt>git-rerere</tt> again records the resolved state of these
429files. Suppose you did this when you created the test merge of
430master into the topic branch.</p>
431<p>Next time, running <tt>git-rerere</tt> after seeing a conflicted
432automerge, if the conflict is the same as the earlier one
433recorded, it is noticed and a three-way merge between the
434earlier conflicted automerge, the earlier manual resolution, and
435the current conflicted automerge is performed by the command.
436If this three-way merge resolves cleanly, the result is written
437out to your working tree file, so you would not have to manually
438resolve it. Note that <tt>git-rerere</tt> leaves the index file alone,
439so you still need to do the final sanity checks with <tt>git diff</tt>
Junio C Hamano89d4e0f2007-02-18 00:34:59440(or <tt>git diff -c</tt>) and <tt>git add</tt> when you are satisfied.</p>
Junio C Hamano40f2f8d2006-02-07 08:04:39441<p>As a convenience measure, <tt>git-merge</tt> automatically invokes
442<tt>git-rerere</tt> when it exits with a failed automerge, which
443records it if it is a new conflict, or reuses the earlier hand
444resolve when it is not. <tt>git-commit</tt> also invokes <tt>git-rerere</tt>
445when recording a merge result. What this means is that you do
446not have to do anything special yourself (Note: you still have
Junio C Hamano7a4a2832007-07-07 21:53:22447to set the config variable rerere.enabled to enable this command).</p>
Junio C Hamano40f2f8d2006-02-07 08:04:39448<p>In our example, when you did the test merge, the manual
449resolution is recorded, and it will be reused when you do the
450actual merge later with updated master and topic branch, as long
451as 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
454development 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
468up-to-date even before your topic is ready to be sent upstream.
469This would result in falling back to three-way merge, and it
470would 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
472conflict.</p>
473</div>
474<h2>Author</h2>
475<div class="sectionbody">
476<p>Written by Junio C Hamano &lt;junkio@cox.net&gt;</p>
477</div>
478<h2>GIT</h2>
479<div class="sectionbody">
Junio C Hamanof7c042d2008-06-06 22:50:53480<p>Part of the <a href="git.html">git(1)</a> suite</p>
Junio C Hamano40f2f8d2006-02-07 08:04:39481</div>
482<div id="footer">
483<div id="footer-text">
Junio C Hamanoe2b205c2008-06-08 01:43:44484Last updated 08-Jun-2008 01:34:06 UTC
Junio C Hamano40f2f8d2006-02-07 08:04:39485</div>
486</div>
487</body>
488</html>