blob: 20790b54a6aa158b4266eba58eaaedacd8ab0afc [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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 Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamano1a4e8412005-12-27 08:17:237<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
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1a4e8412005-12-27 08:17:2326
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, 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 Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2384}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#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}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.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}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1a4e8412005-12-27 08:17:23155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
172div.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}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1a4e8412005-12-27 08:17:23236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#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
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1a4e8412005-12-27 08:17:23275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.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
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-merge(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-merge(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-merge -
Junio C Hamano7c73c662007-01-19 00:37:50317 Join two or more development histories together
Junio C Hamano1a4e8412005-12-27 08:17:23318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoee6d9612006-11-27 20:03:22323<div class="verseblock">
Junio C Hamanob04bb3f2010-04-14 14:07:36324<div class="content"><em>git merge</em> [-n] [--stat] [--no-commit] [--squash]
325 [-s &lt;strategy&gt;] [-X &lt;strategy-option&gt;]
Junio C Hamano1aa40d22010-01-21 17:46:43326 [--[no-]rerere-autoupdate] [-m &lt;msg&gt;] &lt;commit&gt;&#8230;
327<em>git merge</em> &lt;msg&gt; HEAD &lt;commit&gt;&#8230;</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23328</div>
Junio C Hamanoba4b9282008-07-06 05:20:31329<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23330<div class="sectionbody">
Junio C Hamanod0d892c2010-01-24 20:06:29331<div class="para"><p>Incorporates changes from the named commits (since the time their
332histories diverged from the current branch) into the current
333branch. This command is used by <em>git pull</em> to incorporate changes
334from another repository and can be used by hand to merge changes
335from one branch into another.</p></div>
336<div class="para"><p>Assume the following history exists and the current branch is
337"<tt>master</tt>":</p></div>
338<div class="listingblock">
339<div class="content">
340<pre><tt> A---B---C topic
341 /
342 D---E---F---G master</tt></pre>
343</div></div>
344<div class="para"><p>Then "<tt>git merge topic</tt>" will replay the changes made on the
345<tt>topic</tt> branch since it diverged from <tt>master</tt> (i.e., <tt>E</tt>) until
346its current commit (<tt>C</tt>) on top of <tt>master</tt>, and record the result
347in a new commit along with the names of the two parent commits and
348a log message from the user describing the changes.</p></div>
349<div class="listingblock">
350<div class="content">
351<pre><tt> A---B---C topic
352 / \
353 D---E---F---G---H master</tt></pre>
354</div></div>
Junio C Hamano1aa40d22010-01-21 17:46:43355<div class="para"><p>The second syntax (&lt;msg&gt; <tt>HEAD</tt> &lt;commit&gt;&#8230;) is supported for
Junio C Hamano1974bf22007-10-31 05:57:20356historical reasons. Do not use it from the command line or in
Junio C Hamano1aa40d22010-01-21 17:46:43357new scripts. It is the same as <tt>git merge -m &lt;msg&gt; &lt;commit&gt;&#8230;</tt>.</p></div>
358<div class="para"><p><strong>Warning</strong>: Running <em>git merge</em> with uncommitted changes is
359discouraged: while possible, it leaves you in a state that is hard to
360back out of in the case of a conflict.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23361</div>
Junio C Hamanoba4b9282008-07-06 05:20:31362<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23363<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31364<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23365<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55366--commit
367</dt>
368<dt>
369--no-commit
370</dt>
371<dd>
372<p>
373 Perform the merge and commit the result. This option can
374 be used to override --no-commit.
375</p>
376<div class="para"><p>With --no-commit perform the merge but pretend the merge
377failed and do not autocommit, to give the user a chance to
378inspect and further tweak the merge result before committing.</p></div>
379</dd>
380<dt>
381--ff
382</dt>
383<dt>
384--no-ff
385</dt>
386<dd>
387<p>
388 Do not generate a merge commit if the merge resolved as
389 a fast-forward, only update the branch pointer. This is
390 the default behavior of git-merge.
391</p>
392<div class="para"><p>With --no-ff Generate a merge commit even if the merge
393resolved as a fast-forward.</p></div>
394</dd>
395<dt>
Junio C Hamano3b4609d2010-09-30 00:04:34396--log[=&lt;n&gt;]
Junio C Hamanoc21ab052009-10-31 04:03:55397</dt>
398<dt>
399--no-log
400</dt>
401<dd>
402<p>
403 In addition to branch names, populate the log message with
Junio C Hamano3b4609d2010-09-30 00:04:34404 one-line descriptions from at most &lt;n&gt; actual commits that are being
405 merged. See also <a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>.
Junio C Hamanoc21ab052009-10-31 04:03:55406</p>
407<div class="para"><p>With --no-log do not list one-line descriptions from the
408actual commits being merged.</p></div>
409</dd>
410<dt>
411--stat
412</dt>
413<dt>
414-n
415</dt>
416<dt>
417--no-stat
418</dt>
419<dd>
420<p>
421 Show a diffstat at the end of the merge. The diffstat is also
422 controlled by the configuration option merge.stat.
423</p>
424<div class="para"><p>With -n or --no-stat do not show a diffstat at the end of the
425merge.</p></div>
426</dd>
427<dt>
428--squash
429</dt>
430<dt>
431--no-squash
432</dt>
433<dd>
434<p>
435 Produce the working tree and index state as if a real
436 merge happened (except for the merge information),
437 but do not actually make a commit or
438 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
439 cause the next <tt>git commit</tt> command to create a merge
440 commit. This allows you to create a single commit on
441 top of the current branch whose effect is the same as
442 merging another branch (or more in case of an octopus).
443</p>
444<div class="para"><p>With --no-squash perform the merge and commit the result. This
445option can be used to override --squash.</p></div>
446</dd>
447<dt>
Junio C Hamano446ed772009-11-10 22:02:20448--ff-only
449</dt>
450<dd>
451<p>
452 Refuse to merge and exit with a non-zero status unless the
453 current <tt>HEAD</tt> is already up-to-date or the merge can be
454 resolved as a fast-forward.
455</p>
456</dd>
457<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55458-s &lt;strategy&gt;
459</dt>
460<dt>
461--strategy=&lt;strategy&gt;
462</dt>
463<dd>
464<p>
465 Use the given merge strategy; can be supplied more than
466 once to specify them in the order they should be tried.
467 If there is no <tt>-s</tt> option, a built-in list of strategies
Junio C Hamano1aa40d22010-01-21 17:46:43468 is used instead (<em>git merge-recursive</em> when merging a single
469 head, <em>git merge-octopus</em> otherwise).
Junio C Hamanoc21ab052009-10-31 04:03:55470</p>
471</dd>
472<dt>
Junio C Hamanob04bb3f2010-04-14 14:07:36473-X &lt;option&gt;
474</dt>
475<dt>
476--strategy-option=&lt;option&gt;
477</dt>
478<dd>
479<p>
480 Pass merge strategy specific option through to the merge
481 strategy.
482</p>
483</dd>
484<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55485--summary
486</dt>
487<dt>
488--no-summary
489</dt>
490<dd>
491<p>
492 Synonyms to --stat and --no-stat; these are deprecated and will be
493 removed in the future.
494</p>
495</dd>
496<dt>
Junio C Hamano610d1762008-11-28 06:27:13497-q
498</dt>
499<dt>
500--quiet
501</dt>
502<dd>
503<p>
504 Operate quietly.
505</p>
506</dd>
507<dt>
508-v
509</dt>
510<dt>
511--verbose
512</dt>
513<dd>
514<p>
515 Be verbose.
516</p>
517</dd>
518<dt>
Junio C Hamano1974bf22007-10-31 05:57:20519-m &lt;msg&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23520</dt>
521<dd>
522<p>
Junio C Hamanoc0e55e72009-10-10 00:56:29523 Set the commit message to be used for the merge commit (in
Junio C Hamanof5de4cf2010-06-19 00:33:17524 case one is created).
Junio C Hamano1a4e8412005-12-27 08:17:23525</p>
Junio C Hamanof5de4cf2010-06-19 00:33:17526<div class="literalblock">
527<div class="content">
528<pre><tt>If `--log` is specified, a shortlog of the commits being merged
529will be appended to the specified message.</tt></pre>
530</div></div>
531<div class="literalblock">
532<div class="content">
533<pre><tt>The 'git fmt-merge-msg' command can be
534used to give a good default for automated 'git merge'
535invocations.</tt></pre>
536</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23537</dd>
538<dt>
Junio C Hamano19107ef2010-01-19 06:20:59539--rerere-autoupdate
540</dt>
541<dt>
542--no-rerere-autoupdate
543</dt>
544<dd>
545<p>
546 Allow the rerere mechanism to update the index with the
547 result of auto-conflict resolution if possible.
548</p>
549</dd>
550<dt>
Junio C Hamano1aa40d22010-01-21 17:46:43551&lt;commit&gt;&#8230;
Junio C Hamano1a4e8412005-12-27 08:17:23552</dt>
553<dd>
554<p>
Junio C Hamano1aa40d22010-01-21 17:46:43555 Commits, usually other branch heads, to merge into our branch.
556 You need at least one &lt;commit&gt;. Specifying more than one
557 &lt;commit&gt; obviously means you are trying an Octopus.
Junio C Hamano1a4e8412005-12-27 08:17:23558</p>
559</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31560</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23561</div>
Junio C Hamanod0d892c2010-01-24 20:06:29562<h2 id="_pre_merge_checks">PRE-MERGE CHECKS</h2>
563<div class="sectionbody">
564<div class="para"><p>Before applying outside changes, you should get your own work in
565good shape and committed locally, so it will not be clobbered if
566there are conflicts. See also <a href="git-stash.html">git-stash(1)</a>.
567<em>git pull</em> and <em>git merge</em> will stop without doing anything when
568local uncommitted changes overlap with files that <em>git pull</em>/<em>git
569merge</em> may need to update.</p></div>
570<div class="para"><p>To avoid recording unrelated changes in the merge commit,
571<em>git pull</em> and <em>git merge</em> will also abort if there are any changes
572registered in the index relative to the <tt>HEAD</tt> commit. (One
573exception is when the changed index entries are in the state that
574would result from the merge already.)</p></div>
575<div class="para"><p>If all named commits are already ancestors of <tt>HEAD</tt>, <em>git merge</em>
576will exit early with the message "Already up-to-date."</p></div>
577</div>
578<h2 id="_fast_forward_merge">FAST-FORWARD MERGE</h2>
579<div class="sectionbody">
580<div class="para"><p>Often the current branch head is an ancestor of the named commit.
581This is the most common case especially when invoked from <em>git
582pull</em>: you are tracking an upstream repository, you have committed
583no local changes, and now you want to update to a newer upstream
584revision. In this case, a new commit is not needed to store the
585combined history; instead, the <tt>HEAD</tt> (along with the index) is
586updated to point at the named commit, without creating an extra
587merge commit.</p></div>
588<div class="para"><p>This behavior can be suppressed with the <tt>--no-ff</tt> option.</p></div>
589</div>
590<h2 id="_true_merge">TRUE MERGE</h2>
591<div class="sectionbody">
592<div class="para"><p>Except in a fast-forward merge (see above), the branches to be
593merged must be tied together by a merge commit that has both of them
594as its parents.</p></div>
595<div class="para"><p>A merged version reconciling the changes from all branches to be
596merged is committed, and your <tt>HEAD</tt>, index, and working tree are
597updated to it. It is possible to have modifications in the working
598tree as long as they do not overlap; the update will preserve them.</p></div>
599<div class="para"><p>When it is not obvious how to reconcile the changes, the following
600happens:</p></div>
601<div class="olist"><ol>
602<li>
603<p>
604The <tt>HEAD</tt> pointer stays the same.
605</p>
606</li>
607<li>
608<p>
609The <tt>MERGE_HEAD</tt> ref is set to point to the other branch head.
610</p>
611</li>
612<li>
613<p>
614Paths that merged cleanly are updated both in the index file and
615 in your working tree.
616</p>
617</li>
618<li>
619<p>
620For conflicting paths, the index file records up to three
621 versions: stage 1 stores the version from the common ancestor,
622 stage 2 from <tt>HEAD</tt>, and stage 3 from <tt>MERGE_HEAD</tt> (you
623 can inspect the stages with <tt>git ls-files -u</tt>). The working
624 tree files contain the result of the "merge" program; i.e. 3-way
625 merge results with familiar conflict markers <tt>&lt;&lt;&lt;</tt> <tt>===</tt> <tt>&gt;&gt;&gt;</tt>.
626</p>
627</li>
628<li>
629<p>
630No other changes are made. In particular, the local
631 modifications you had before you started merge will stay the
632 same and the index entries for them stay as they were,
633 i.e. matching <tt>HEAD</tt>.
634</p>
635</li>
636</ol></div>
637<div class="para"><p>If you tried a merge which resulted in complex conflicts and
638want to start over, you can recover with <tt>git reset --merge</tt>.</p></div>
639</div>
640<h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
641<div class="sectionbody">
642<div class="para"><p>During a merge, the working tree files are updated to reflect the result
643of the merge. Among the changes made to the common ancestor's version,
644non-overlapping ones (that is, you changed an area of the file while the
645other side left that area intact, or vice versa) are incorporated in the
646final result verbatim. When both sides made changes to the same area,
647however, git cannot randomly pick one side over the other, and asks you to
648resolve it by leaving what both sides did to that area.</p></div>
649<div class="para"><p>By default, git uses the same style as that is used by "merge" program
650from the RCS suite to present such a conflicted hunk, like this:</p></div>
651<div class="listingblock">
652<div class="content">
653<pre><tt>Here are lines that are either unchanged from the common
654ancestor, or cleanly resolved because only one side changed.
655&lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
656Conflict resolution is hard;
657let's go shopping.
658=======
659Git makes conflict resolution easy.
660&gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
661And here is another line that is cleanly resolved or unmodified.</tt></pre>
662</div></div>
663<div class="para"><p>The area where a pair of conflicting changes happened is marked with markers
664<tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>, <tt>=======</tt>, and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt>. The part before the <tt>=======</tt>
665is typically your side, and the part afterwards is typically their side.</p></div>
666<div class="para"><p>The default format does not show what the original said in the conflicting
667area. You cannot tell how many lines are deleted and replaced with
668Barbie's remark on your side. The only thing you can tell is that your
669side wants to say it is hard and you'd prefer to go shopping, while the
670other side wants to claim it is easy.</p></div>
671<div class="para"><p>An alternative style can be used by setting the "merge.conflictstyle"
672configuration variable to "diff3". In "diff3" style, the above conflict
673may look like this:</p></div>
674<div class="listingblock">
675<div class="content">
676<pre><tt>Here are lines that are either unchanged from the common
677ancestor, or cleanly resolved because only one side changed.
678&lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
679Conflict resolution is hard;
680let's go shopping.
681|||||||
682Conflict resolution is hard.
683=======
684Git makes conflict resolution easy.
685&gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
686And here is another line that is cleanly resolved or unmodified.</tt></pre>
687</div></div>
688<div class="para"><p>In addition to the <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt>, <tt>=======</tt>, and <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> markers, it uses
689another <tt>|||||||</tt> marker that is followed by the original text. You can
690tell that the original just stated a fact, and your side simply gave in to
691that statement and gave up, while the other side tried to have a more
692positive attitude. You can sometimes come up with a better resolution by
693viewing the original.</p></div>
694</div>
695<h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
696<div class="sectionbody">
697<div class="para"><p>After seeing a conflict, you can do two things:</p></div>
698<div class="ilist"><ul>
699<li>
700<p>
701Decide not to merge. The only clean-ups you need are to reset
702 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
703 up working tree changes made by 2. and 3.; <tt>git-reset --hard</tt> can
704 be used for this.
705</p>
706</li>
707<li>
708<p>
709Resolve the conflicts. Git will mark the conflicts in
710 the working tree. Edit the files into shape and
711 <em>git add</em> them to the index. Use <em>git commit</em> to seal the deal.
712</p>
713</li>
714</ul></div>
715<div class="para"><p>You can work through the conflict with a number of tools:</p></div>
716<div class="ilist"><ul>
717<li>
718<p>
719Use a mergetool. <tt>git mergetool</tt> to launch a graphical
720 mergetool which will work you through the merge.
721</p>
722</li>
723<li>
724<p>
725Look at the diffs. <tt>git diff</tt> will show a three-way diff,
726 highlighting changes from both the <tt>HEAD</tt> and <tt>MERGE_HEAD</tt>
727 versions.
728</p>
729</li>
730<li>
731<p>
732Look at the diffs from each branch. <tt>git log --merge -p &lt;path&gt;</tt>
733 will show diffs first for the <tt>HEAD</tt> version and then the
734 <tt>MERGE_HEAD</tt> version.
735</p>
736</li>
737<li>
738<p>
739Look at the originals. <tt>git show :1:filename</tt> shows the
740 common ancestor, <tt>git show :2:filename</tt> shows the <tt>HEAD</tt>
741 version, and <tt>git show :3:filename</tt> shows the <tt>MERGE_HEAD</tt>
742 version.
743</p>
744</li>
745</ul></div>
746</div>
747<h2 id="_examples">EXAMPLES</h2>
748<div class="sectionbody">
749<div class="ilist"><ul>
750<li>
751<p>
752Merge branches <tt>fixes</tt> and <tt>enhancements</tt> on top of
753 the current branch, making an octopus merge:
754</p>
755<div class="listingblock">
756<div class="content">
757<pre><tt>$ git merge fixes enhancements</tt></pre>
758</div></div>
759</li>
760<li>
761<p>
762Merge branch <tt>obsolete</tt> into the current branch, using <tt>ours</tt>
763 merge strategy:
764</p>
765<div class="listingblock">
766<div class="content">
767<pre><tt>$ git merge -s ours obsolete</tt></pre>
768</div></div>
769</li>
770<li>
771<p>
772Merge branch <tt>maint</tt> into the current branch, but do not make
773 a new commit automatically:
774</p>
775<div class="listingblock">
776<div class="content">
777<pre><tt>$ git merge --no-commit maint</tt></pre>
778</div></div>
779<div class="para"><p>This can be used when you want to include further changes to the
780merge, or want to write your own merge commit message.</p></div>
781<div class="para"><p>You should refrain from abusing this option to sneak substantial
782changes into a merge commit. Small fixups like bumping
783release/version name would be acceptable.</p></div>
784</li>
785</ul></div>
786</div>
Junio C Hamanoba4b9282008-07-06 05:20:31787<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23788<div class="sectionbody">
Junio C Hamano1aa40d22010-01-21 17:46:43789<div class="para"><p>The merge mechanism (<em>git-merge</em> and <em>git-pull</em> commands) allows the
790backend <em>merge strategies</em> to be chosen with <tt>-s</tt> option. Some strategies
791can also take their own options, which can be passed by giving <tt>-X&lt;option&gt;</tt>
792arguments to <em>git-merge</em> and/or <em>git-pull</em>.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31793<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23794<dt>
795resolve
796</dt>
797<dd>
798<p>
799 This can only resolve two heads (i.e. the current branch
Junio C Hamano1de75722009-03-26 08:39:38800 and another branch you pulled from) using a 3-way merge
Junio C Hamano1a4e8412005-12-27 08:17:23801 algorithm. It tries to carefully detect criss-cross
802 merge ambiguities and is considered generally safe and
803 fast.
804</p>
805</dd>
806<dt>
807recursive
808</dt>
809<dd>
810<p>
Junio C Hamano1de75722009-03-26 08:39:38811 This can only resolve two heads using a 3-way merge
812 algorithm. When there is more than one common
813 ancestor that can be used for 3-way merge, it creates a
Junio C Hamano1a4e8412005-12-27 08:17:23814 merged tree of the common ancestors and uses that as
815 the reference tree for the 3-way merge. This has been
816 reported to result in fewer merge conflicts without
817 causing mis-merges by tests done on actual merge commits
818 taken from Linux 2.6 kernel development history.
819 Additionally this can detect and handle merges involving
820 renames. This is the default merge strategy when
821 pulling or merging one branch.
822</p>
Junio C Hamano1aa40d22010-01-21 17:46:43823<div class="para"><p>The <em>recursive</em> strategy can take the following options:</p></div>
824<div class="vlist"><dl>
825<dt>
826ours
827</dt>
828<dd>
829<p>
830 This option forces conflicting hunks to be auto-resolved cleanly by
831 favoring <em>our</em> version. Changes from the other tree that do not
832 conflict with our side are reflected to the merge result.
833</p>
834<div class="para"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
835even look at what the other tree contains at all. It discards everything
836the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
837</dd>
838<dt>
839theirs
840</dt>
841<dd>
842<p>
843 This is opposite of <em>ours</em>.
844</p>
845</dd>
846<dt>
Junio C Hamano39c7a692010-10-27 06:08:54847patience
848</dt>
849<dd>
850<p>
851 With this option, <em>merge-recursive</em> spends a little extra time
852 to avoid mismerges that sometimes occur due to unimportant
853 matching lines (e.g., braces from distinct functions). Use
854 this when the branches to be merged have diverged wildly.
855 See also <a href="git-diff.html">git-diff(1)</a> <tt>--patience</tt>.
856</p>
857</dd>
858<dt>
859ignore-space-change
860</dt>
861<dt>
862ignore-all-space
863</dt>
864<dt>
865ignore-space-at-eol
866</dt>
867<dd>
868<p>
869 Treats lines with the indicated type of whitespace change as
870 unchanged for the sake of a three-way merge. Whitespace
871 changes mixed with other changes to a line are not ignored.
872 See also <a href="git-diff.html">git-diff(1)</a> <tt>-b</tt>, <tt>-w</tt>, and
873 <tt>--ignore-space-at-eol</tt>.
874</p>
875<div class="ilist"><ul>
876<li>
877<p>
878If <em>their</em> version only introduces whitespace changes to a line,
879 <em>our</em> version is used;
880</p>
881</li>
882<li>
883<p>
884If <em>our</em> version introduces whitespace changes but <em>their</em>
885 version includes a substantial change, <em>their</em> version is used;
886</p>
887</li>
888<li>
889<p>
890Otherwise, the merge proceeds in the usual way.
891</p>
892</li>
893</ul></div>
894</dd>
895<dt>
Junio C Hamano2db3e752010-09-03 21:33:06896renormalize
897</dt>
898<dd>
899<p>
900 This runs a virtual check-out and check-in of all three stages
901 of a file when resolving a three-way merge. This option is
902 meant to be used when merging branches with different clean
903 filters or end-of-line normalization rules. See "Merging
904 branches with differing checkin/checkout attributes" in
905 <a href="gitattributes.html">gitattributes(5)</a> for details.
906</p>
907</dd>
908<dt>
909no-renormalize
910</dt>
911<dd>
912<p>
913 Disables the <tt>renormalize</tt> option. This overrides the
914 <tt>merge.renormalize</tt> configuration variable.
915</p>
916</dd>
917<dt>
Junio C Hamano39c7a692010-10-27 06:08:54918rename-threshold=&lt;n&gt;
919</dt>
920<dd>
921<p>
922 Controls the similarity threshold used for rename detection.
923 See also <a href="git-diff.html">git-diff(1)</a> <tt>-M</tt>.
924</p>
925</dd>
926<dt>
Junio C Hamanod2179ef2010-10-22 04:12:17927subtree[=&lt;path&gt;]
Junio C Hamano1aa40d22010-01-21 17:46:43928</dt>
929<dd>
930<p>
931 This option is a more advanced form of <em>subtree</em> strategy, where
932 the strategy makes a guess on how two trees must be shifted to
933 match with each other when merging. Instead, the specified path
934 is prefixed (or stripped from the beginning) to make the shape of
935 two trees to match.
936</p>
937</dd>
938</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23939</dd>
940<dt>
941octopus
942</dt>
943<dd>
944<p>
Junio C Hamano1de75722009-03-26 08:39:38945 This resolves cases with more than two heads, but refuses to do
946 a complex merge that needs manual resolution. It is
Junio C Hamano1a4e8412005-12-27 08:17:23947 primarily meant to be used for bundling topic branch
948 heads together. This is the default merge strategy when
Junio C Hamano1de75722009-03-26 08:39:38949 pulling or merging more than one branch.
Junio C Hamano1a4e8412005-12-27 08:17:23950</p>
951</dd>
952<dt>
953ours
954</dt>
955<dd>
956<p>
Junio C Hamanobf984de2009-11-23 06:11:19957 This resolves any number of heads, but the resulting tree of the
958 merge is always that of the current branch head, effectively
959 ignoring all changes from all other branches. It is meant to
Junio C Hamano1a4e8412005-12-27 08:17:23960 be used to supersede old development history of side
Junio C Hamano1aa40d22010-01-21 17:46:43961 branches. Note that this is different from the -Xours option to
962 the <em>recursive</em> merge strategy.
Junio C Hamano1a4e8412005-12-27 08:17:23963</p>
964</dd>
Junio C Hamanoe6c92032008-03-19 09:24:34965<dt>
966subtree
967</dt>
968<dd>
969<p>
970 This is a modified recursive strategy. When merging trees A and
971 B, if B corresponds to a subtree of A, B is first adjusted to
972 match the tree structure of A, instead of reading the trees at
973 the same level. This adjustment is also done to the common
974 ancestor tree.
975</p>
976</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31977</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23978</div>
Junio C Hamanoba4b9282008-07-06 05:20:31979<h2 id="_configuration">CONFIGURATION</h2>
Junio C Hamano1e6e0062007-07-13 05:33:25980<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31981<div class="vlist"><dl>
Junio C Hamano1e6e0062007-07-13 05:33:25982<dt>
Junio C Hamano4653c6f2008-11-26 22:50:20983merge.conflictstyle
Junio C Hamano1e6e0062007-07-13 05:33:25984</dt>
985<dd>
986<p>
Junio C Hamano4653c6f2008-11-26 22:50:20987 Specify the style in which conflicted hunks are written out to
988 working tree files upon merge. The default is "merge", which
Junio C Hamanoec87f522008-12-10 08:35:25989 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
990 a <tt>=======</tt> marker, changes made by the other side, and then
991 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
992 marker and the original text before the <tt>=======</tt> marker.
Junio C Hamano6d76d612008-05-09 05:46:08993</p>
994</dd>
995<dt>
996merge.log
997</dt>
998<dd>
999<p>
Junio C Hamano3b4609d2010-09-30 00:04:341000 In addition to branch names, populate the log message with at
1001 most the specified number of one-line descriptions from the
1002 actual commits that are being merged. Defaults to false, and
1003 true is a synoym for 20.
Junio C Hamano6d76d612008-05-09 05:46:081004</p>
1005</dd>
1006<dt>
Junio C Hamano2fbcd212008-05-14 22:26:071007merge.renameLimit
1008</dt>
1009<dd>
1010<p>
1011 The number of files to consider when performing rename detection
1012 during a merge; if not specified, defaults to the value of
1013 diff.renameLimit.
1014</p>
1015</dd>
1016<dt>
Junio C Hamano2db3e752010-09-03 21:33:061017merge.renormalize
1018</dt>
1019<dd>
1020<p>
1021 Tell git that canonical representation of files in the
1022 repository has changed over time (e.g. earlier commits record
1023 text files with CRLF line endings, but recent ones use LF line
1024 endings). In such a repository, git can convert the data
1025 recorded in commits to a canonical form before performing a
1026 merge to reduce unnecessary conflicts. For more information,
1027 see section "Merging branches with differing checkin/checkout
1028 attributes" in <a href="gitattributes.html">gitattributes(5)</a>.
1029</p>
1030</dd>
1031<dt>
Junio C Hamano4653c6f2008-11-26 22:50:201032merge.stat
1033</dt>
1034<dd>
1035<p>
1036 Whether to print the diffstat between ORIG_HEAD and the merge result
1037 at the end of the merge. True by default.
1038</p>
1039</dd>
1040<dt>
Junio C Hamano6d76d612008-05-09 05:46:081041merge.tool
1042</dt>
1043<dd>
1044<p>
1045 Controls which merge resolution program is used by
1046 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "kdiff3",
Junio C Hamano3bd66e92009-04-18 06:17:561047 "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff",
Junio C Hamano3f680f32009-11-16 02:10:541048 "diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis" and
Junio C Hamano6d76d612008-05-09 05:46:081049 "opendiff". Any other value is treated is custom merge tool
Junio C Hamanocb1c44f2008-08-06 06:19:331050 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
Junio C Hamano1e6e0062007-07-13 05:33:251051</p>
1052</dd>
1053<dt>
1054merge.verbosity
1055</dt>
1056<dd>
1057<p>
1058 Controls the amount of output shown by the recursive merge
1059 strategy. Level 0 outputs nothing except a final error
1060 message if conflicts were detected. Level 1 outputs only
1061 conflicts, 2 outputs conflicts and file changes. Level 5 and
1062 above outputs debugging information. The default is level 2.
Junio C Hamanoec87f522008-12-10 08:35:251063 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
Junio C Hamano1e6e0062007-07-13 05:33:251064</p>
1065</dd>
Junio C Hamano1b50ce92007-10-03 12:05:531066<dt>
Junio C Hamano6d76d612008-05-09 05:46:081067merge.&lt;driver&gt;.name
1068</dt>
1069<dd>
1070<p>
Junio C Hamanoec87f522008-12-10 08:35:251071 Defines a human-readable name for a custom low-level
Junio C Hamano6d76d612008-05-09 05:46:081072 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1073</p>
1074</dd>
1075<dt>
1076merge.&lt;driver&gt;.driver
1077</dt>
1078<dd>
1079<p>
1080 Defines the command that implements a custom low-level
1081 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1082</p>
1083</dd>
1084<dt>
1085merge.&lt;driver&gt;.recursive
1086</dt>
1087<dd>
1088<p>
1089 Names a low-level merge driver to be used when
1090 performing an internal merge between common ancestors.
1091 See <a href="gitattributes.html">gitattributes(5)</a> for details.
1092</p>
1093</dd>
1094<dt>
Junio C Hamano1b50ce92007-10-03 12:05:531095branch.&lt;name&gt;.mergeoptions
1096</dt>
1097<dd>
1098<p>
1099 Sets default options for merging into branch &lt;name&gt;. The syntax and
Junio C Hamanoc0e55e72009-10-10 00:56:291100 supported options are the same as those of <em>git merge</em>, but option
1101 values containing whitespace characters are currently not supported.
Junio C Hamano1b50ce92007-10-03 12:05:531102</p>
1103</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311104</dl></div>
Junio C Hamano1e6e0062007-07-13 05:33:251105</div>
Junio C Hamanoba4b9282008-07-06 05:20:311106<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231107<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311108<div class="para"><p><a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>, <a href="git-pull.html">git-pull(1)</a>,
Junio C Hamanofce7c7e2008-07-02 03:06:381109<a href="gitattributes.html">gitattributes(5)</a>,
1110<a href="git-reset.html">git-reset(1)</a>,
1111<a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1112<a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
Junio C Hamanoba4b9282008-07-06 05:20:311113<a href="git-mergetool.html">git-mergetool(1)</a></p></div>
Junio C Hamanofa2ad882009-12-03 09:15:441114</div>
1115<h2 id="_author">Author</h2>
1116<div class="sectionbody">
1117<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
1118</div>
1119<h2 id="_documentation">Documentation</h2>
1120<div class="sectionbody">
1121<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
1122</div>
1123<h2 id="_git">GIT</h2>
1124<div class="sectionbody">
1125<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1126</div>
1127<div id="footer">
1128<div id="footer-text">
Junio C Hamano39c7a692010-10-27 06:08:541129Last updated 2010-10-27 06:08:20 UTC
Junio C Hamanofa2ad882009-12-03 09:15:441130</div>
1131</div>
1132</body>
1133</html>