Autogenerated HTML docs for v1.7.4-rc2
[git/jnareb-git.git] / git-merge.html
blob1f1ffb8860e455252721a43f96c620cef660ad9e
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 8.4.5" />
7 <title>git-merge(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-merge(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-merge -
411 Join two or more development histories together
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git merge</em> [-n] [--stat] [--no-commit] [--squash]
419 [-s &lt;strategy&gt;] [-X &lt;strategy-option&gt;]
420 [--[no-]rerere-autoupdate] [-m &lt;msg&gt;] &lt;commit&gt;&#8230;
421 <em>git merge</em> &lt;msg&gt; HEAD &lt;commit&gt;&#8230;
422 <em>git merge</em> --abort</div>
423 <div class="verseblock-attribution">
424 </div></div>
425 </div>
426 <h2 id="_description">DESCRIPTION</h2>
427 <div class="sectionbody">
428 <div class="paragraph"><p>Incorporates changes from the named commits (since the time their
429 histories diverged from the current branch) into the current
430 branch. This command is used by <em>git pull</em> to incorporate changes
431 from another repository and can be used by hand to merge changes
432 from one branch into another.</p></div>
433 <div class="paragraph"><p>Assume the following history exists and the current branch is
434 "<tt>master</tt>":</p></div>
435 <div class="listingblock">
436 <div class="content">
437 <pre><tt> A---B---C topic
439 D---E---F---G master</tt></pre>
440 </div></div>
441 <div class="paragraph"><p>Then "<tt>git merge topic</tt>" will replay the changes made on the
442 <tt>topic</tt> branch since it diverged from <tt>master</tt> (i.e., <tt>E</tt>) until
443 its current commit (<tt>C</tt>) on top of <tt>master</tt>, and record the result
444 in a new commit along with the names of the two parent commits and
445 a log message from the user describing the changes.</p></div>
446 <div class="listingblock">
447 <div class="content">
448 <pre><tt> A---B---C topic
450 D---E---F---G---H master</tt></pre>
451 </div></div>
452 <div class="paragraph"><p>The second syntax (&lt;msg&gt; <tt>HEAD</tt> &lt;commit&gt;&#8230;) is supported for
453 historical reasons. Do not use it from the command line or in
454 new scripts. It is the same as <tt>git merge -m &lt;msg&gt; &lt;commit&gt;&#8230;</tt>.</p></div>
455 <div class="paragraph"><p>The third syntax ("<tt>git merge --abort</tt>") can only be run after the
456 merge has resulted in conflicts. <em>git merge --abort</em> will abort the
457 merge process and try to reconstruct the pre-merge state. However,
458 if there were uncommitted changes when the merge started (and
459 especially if those changes were further modified after the merge
460 was started), <em>git merge --abort</em> will in some cases be unable to
461 reconstruct the original (pre-merge) changes. Therefore:</p></div>
462 <div class="paragraph"><p><strong>Warning</strong>: Running <em>git merge</em> with uncommitted changes is
463 discouraged: while possible, it leaves you in a state that is hard to
464 back out of in the case of a conflict.</p></div>
465 </div>
466 <h2 id="_options">OPTIONS</h2>
467 <div class="sectionbody">
468 <div class="dlist"><dl>
469 <dt class="hdlist1">
470 --commit
471 </dt>
472 <dt class="hdlist1">
473 --no-commit
474 </dt>
475 <dd>
477 Perform the merge and commit the result. This option can
478 be used to override --no-commit.
479 </p>
480 <div class="paragraph"><p>With --no-commit perform the merge but pretend the merge
481 failed and do not autocommit, to give the user a chance to
482 inspect and further tweak the merge result before committing.</p></div>
483 </dd>
484 <dt class="hdlist1">
485 --ff
486 </dt>
487 <dt class="hdlist1">
488 --no-ff
489 </dt>
490 <dd>
492 Do not generate a merge commit if the merge resolved as
493 a fast-forward, only update the branch pointer. This is
494 the default behavior of git-merge.
495 </p>
496 <div class="paragraph"><p>With --no-ff Generate a merge commit even if the merge
497 resolved as a fast-forward.</p></div>
498 </dd>
499 <dt class="hdlist1">
500 --log[=&lt;n&gt;]
501 </dt>
502 <dt class="hdlist1">
503 --no-log
504 </dt>
505 <dd>
507 In addition to branch names, populate the log message with
508 one-line descriptions from at most &lt;n&gt; actual commits that are being
509 merged. See also <a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>.
510 </p>
511 <div class="paragraph"><p>With --no-log do not list one-line descriptions from the
512 actual commits being merged.</p></div>
513 </dd>
514 <dt class="hdlist1">
515 --stat
516 </dt>
517 <dt class="hdlist1">
519 </dt>
520 <dt class="hdlist1">
521 --no-stat
522 </dt>
523 <dd>
525 Show a diffstat at the end of the merge. The diffstat is also
526 controlled by the configuration option merge.stat.
527 </p>
528 <div class="paragraph"><p>With -n or --no-stat do not show a diffstat at the end of the
529 merge.</p></div>
530 </dd>
531 <dt class="hdlist1">
532 --squash
533 </dt>
534 <dt class="hdlist1">
535 --no-squash
536 </dt>
537 <dd>
539 Produce the working tree and index state as if a real
540 merge happened (except for the merge information),
541 but do not actually make a commit or
542 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
543 cause the next <tt>git commit</tt> command to create a merge
544 commit. This allows you to create a single commit on
545 top of the current branch whose effect is the same as
546 merging another branch (or more in case of an octopus).
547 </p>
548 <div class="paragraph"><p>With --no-squash perform the merge and commit the result. This
549 option can be used to override --squash.</p></div>
550 </dd>
551 <dt class="hdlist1">
552 --ff-only
553 </dt>
554 <dd>
556 Refuse to merge and exit with a non-zero status unless the
557 current <tt>HEAD</tt> is already up-to-date or the merge can be
558 resolved as a fast-forward.
559 </p>
560 </dd>
561 <dt class="hdlist1">
562 -s &lt;strategy&gt;
563 </dt>
564 <dt class="hdlist1">
565 --strategy=&lt;strategy&gt;
566 </dt>
567 <dd>
569 Use the given merge strategy; can be supplied more than
570 once to specify them in the order they should be tried.
571 If there is no <tt>-s</tt> option, a built-in list of strategies
572 is used instead (<em>git merge-recursive</em> when merging a single
573 head, <em>git merge-octopus</em> otherwise).
574 </p>
575 </dd>
576 <dt class="hdlist1">
577 -X &lt;option&gt;
578 </dt>
579 <dt class="hdlist1">
580 --strategy-option=&lt;option&gt;
581 </dt>
582 <dd>
584 Pass merge strategy specific option through to the merge
585 strategy.
586 </p>
587 </dd>
588 <dt class="hdlist1">
589 --summary
590 </dt>
591 <dt class="hdlist1">
592 --no-summary
593 </dt>
594 <dd>
596 Synonyms to --stat and --no-stat; these are deprecated and will be
597 removed in the future.
598 </p>
599 </dd>
600 <dt class="hdlist1">
602 </dt>
603 <dt class="hdlist1">
604 --quiet
605 </dt>
606 <dd>
608 Operate quietly.
609 </p>
610 </dd>
611 <dt class="hdlist1">
613 </dt>
614 <dt class="hdlist1">
615 --verbose
616 </dt>
617 <dd>
619 Be verbose.
620 </p>
621 </dd>
622 <dt class="hdlist1">
623 -m &lt;msg&gt;
624 </dt>
625 <dd>
627 Set the commit message to be used for the merge commit (in
628 case one is created).
629 </p>
630 <div class="paragraph"><p>If <tt>--log</tt> is specified, a shortlog of the commits being merged
631 will be appended to the specified message.</p></div>
632 <div class="paragraph"><p>The <em>git fmt-merge-msg</em> command can be
633 used to give a good default for automated <em>git merge</em>
634 invocations.</p></div>
635 </dd>
636 <dt class="hdlist1">
637 --rerere-autoupdate
638 </dt>
639 <dt class="hdlist1">
640 --no-rerere-autoupdate
641 </dt>
642 <dd>
644 Allow the rerere mechanism to update the index with the
645 result of auto-conflict resolution if possible.
646 </p>
647 </dd>
648 <dt class="hdlist1">
649 --abort
650 </dt>
651 <dd>
653 Abort the current conflict resolution process, and
654 try to reconstruct the pre-merge state.
655 </p>
656 <div class="paragraph"><p>If there were uncommitted worktree changes present when the merge
657 started, <em>git merge --abort</em> will in some cases be unable to
658 reconstruct these changes. It is therefore recommended to always
659 commit or stash your changes before running <em>git merge</em>.</p></div>
660 <div class="paragraph"><p><em>git merge --abort</em> is equivalent to <em>git reset --merge</em> when
661 <tt>MERGE_HEAD</tt> is present.</p></div>
662 </dd>
663 <dt class="hdlist1">
664 &lt;commit&gt;&#8230;
665 </dt>
666 <dd>
668 Commits, usually other branch heads, to merge into our branch.
669 You need at least one &lt;commit&gt;. Specifying more than one
670 &lt;commit&gt; obviously means you are trying an Octopus.
671 </p>
672 </dd>
673 </dl></div>
674 </div>
675 <h2 id="_pre_merge_checks">PRE-MERGE CHECKS</h2>
676 <div class="sectionbody">
677 <div class="paragraph"><p>Before applying outside changes, you should get your own work in
678 good shape and committed locally, so it will not be clobbered if
679 there are conflicts. See also <a href="git-stash.html">git-stash(1)</a>.
680 <em>git pull</em> and <em>git merge</em> will stop without doing anything when
681 local uncommitted changes overlap with files that <em>git pull</em>/<em>git
682 merge</em> may need to update.</p></div>
683 <div class="paragraph"><p>To avoid recording unrelated changes in the merge commit,
684 <em>git pull</em> and <em>git merge</em> will also abort if there are any changes
685 registered in the index relative to the <tt>HEAD</tt> commit. (One
686 exception is when the changed index entries are in the state that
687 would result from the merge already.)</p></div>
688 <div class="paragraph"><p>If all named commits are already ancestors of <tt>HEAD</tt>, <em>git merge</em>
689 will exit early with the message "Already up-to-date."</p></div>
690 </div>
691 <h2 id="_fast_forward_merge">FAST-FORWARD MERGE</h2>
692 <div class="sectionbody">
693 <div class="paragraph"><p>Often the current branch head is an ancestor of the named commit.
694 This is the most common case especially when invoked from <em>git
695 pull</em>: you are tracking an upstream repository, you have committed
696 no local changes, and now you want to update to a newer upstream
697 revision. In this case, a new commit is not needed to store the
698 combined history; instead, the <tt>HEAD</tt> (along with the index) is
699 updated to point at the named commit, without creating an extra
700 merge commit.</p></div>
701 <div class="paragraph"><p>This behavior can be suppressed with the <tt>--no-ff</tt> option.</p></div>
702 </div>
703 <h2 id="_true_merge">TRUE MERGE</h2>
704 <div class="sectionbody">
705 <div class="paragraph"><p>Except in a fast-forward merge (see above), the branches to be
706 merged must be tied together by a merge commit that has both of them
707 as its parents.</p></div>
708 <div class="paragraph"><p>A merged version reconciling the changes from all branches to be
709 merged is committed, and your <tt>HEAD</tt>, index, and working tree are
710 updated to it. It is possible to have modifications in the working
711 tree as long as they do not overlap; the update will preserve them.</p></div>
712 <div class="paragraph"><p>When it is not obvious how to reconcile the changes, the following
713 happens:</p></div>
714 <div class="olist arabic"><ol class="arabic">
715 <li>
717 The <tt>HEAD</tt> pointer stays the same.
718 </p>
719 </li>
720 <li>
722 The <tt>MERGE_HEAD</tt> ref is set to point to the other branch head.
723 </p>
724 </li>
725 <li>
727 Paths that merged cleanly are updated both in the index file and
728 in your working tree.
729 </p>
730 </li>
731 <li>
733 For conflicting paths, the index file records up to three
734 versions: stage 1 stores the version from the common ancestor,
735 stage 2 from <tt>HEAD</tt>, and stage 3 from <tt>MERGE_HEAD</tt> (you
736 can inspect the stages with <tt>git ls-files -u</tt>). The working
737 tree files contain the result of the "merge" program; i.e. 3-way
738 merge results with familiar conflict markers <tt>&lt;&lt;&lt;</tt> <tt>===</tt> <tt>&gt;&gt;&gt;</tt>.
739 </p>
740 </li>
741 <li>
743 No other changes are made. In particular, the local
744 modifications you had before you started merge will stay the
745 same and the index entries for them stay as they were,
746 i.e. matching <tt>HEAD</tt>.
747 </p>
748 </li>
749 </ol></div>
750 <div class="paragraph"><p>If you tried a merge which resulted in complex conflicts and
751 want to start over, you can recover with <tt>git merge --abort</tt>.</p></div>
752 </div>
753 <h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
754 <div class="sectionbody">
755 <div class="paragraph"><p>During a merge, the working tree files are updated to reflect the result
756 of the merge. Among the changes made to the common ancestor&#8217;s version,
757 non-overlapping ones (that is, you changed an area of the file while the
758 other side left that area intact, or vice versa) are incorporated in the
759 final result verbatim. When both sides made changes to the same area,
760 however, git cannot randomly pick one side over the other, and asks you to
761 resolve it by leaving what both sides did to that area.</p></div>
762 <div class="paragraph"><p>By default, git uses the same style as that is used by "merge" program
763 from the RCS suite to present such a conflicted hunk, like this:</p></div>
764 <div class="listingblock">
765 <div class="content">
766 <pre><tt>Here are lines that are either unchanged from the common
767 ancestor, or cleanly resolved because only one side changed.
768 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
769 Conflict resolution is hard;
770 let's go shopping.
771 =======
772 Git makes conflict resolution easy.
773 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
774 And here is another line that is cleanly resolved or unmodified.</tt></pre>
775 </div></div>
776 <div class="paragraph"><p>The area where a pair of conflicting changes happened is marked with markers
777 <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>
778 is typically your side, and the part afterwards is typically their side.</p></div>
779 <div class="paragraph"><p>The default format does not show what the original said in the conflicting
780 area. You cannot tell how many lines are deleted and replaced with
781 Barbie&#8217;s remark on your side. The only thing you can tell is that your
782 side wants to say it is hard and you&#8217;d prefer to go shopping, while the
783 other side wants to claim it is easy.</p></div>
784 <div class="paragraph"><p>An alternative style can be used by setting the "merge.conflictstyle"
785 configuration variable to "diff3". In "diff3" style, the above conflict
786 may look like this:</p></div>
787 <div class="listingblock">
788 <div class="content">
789 <pre><tt>Here are lines that are either unchanged from the common
790 ancestor, or cleanly resolved because only one side changed.
791 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
792 Conflict resolution is hard;
793 let's go shopping.
794 |||||||
795 Conflict resolution is hard.
796 =======
797 Git makes conflict resolution easy.
798 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
799 And here is another line that is cleanly resolved or unmodified.</tt></pre>
800 </div></div>
801 <div class="paragraph"><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
802 another <tt>|||||||</tt> marker that is followed by the original text. You can
803 tell that the original just stated a fact, and your side simply gave in to
804 that statement and gave up, while the other side tried to have a more
805 positive attitude. You can sometimes come up with a better resolution by
806 viewing the original.</p></div>
807 </div>
808 <h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
809 <div class="sectionbody">
810 <div class="paragraph"><p>After seeing a conflict, you can do two things:</p></div>
811 <div class="ulist"><ul>
812 <li>
814 Decide not to merge. The only clean-ups you need are to reset
815 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
816 up working tree changes made by 2. and 3.; <tt>git merge --abort</tt>
817 can be used for this.
818 </p>
819 </li>
820 <li>
822 Resolve the conflicts. Git will mark the conflicts in
823 the working tree. Edit the files into shape and
824 <em>git add</em> them to the index. Use <em>git commit</em> to seal the deal.
825 </p>
826 </li>
827 </ul></div>
828 <div class="paragraph"><p>You can work through the conflict with a number of tools:</p></div>
829 <div class="ulist"><ul>
830 <li>
832 Use a mergetool. <tt>git mergetool</tt> to launch a graphical
833 mergetool which will work you through the merge.
834 </p>
835 </li>
836 <li>
838 Look at the diffs. <tt>git diff</tt> will show a three-way diff,
839 highlighting changes from both the <tt>HEAD</tt> and <tt>MERGE_HEAD</tt>
840 versions.
841 </p>
842 </li>
843 <li>
845 Look at the diffs from each branch. <tt>git log --merge -p &lt;path&gt;</tt>
846 will show diffs first for the <tt>HEAD</tt> version and then the
847 <tt>MERGE_HEAD</tt> version.
848 </p>
849 </li>
850 <li>
852 Look at the originals. <tt>git show :1:filename</tt> shows the
853 common ancestor, <tt>git show :2:filename</tt> shows the <tt>HEAD</tt>
854 version, and <tt>git show :3:filename</tt> shows the <tt>MERGE_HEAD</tt>
855 version.
856 </p>
857 </li>
858 </ul></div>
859 </div>
860 <h2 id="_examples">EXAMPLES</h2>
861 <div class="sectionbody">
862 <div class="ulist"><ul>
863 <li>
865 Merge branches <tt>fixes</tt> and <tt>enhancements</tt> on top of
866 the current branch, making an octopus merge:
867 </p>
868 <div class="listingblock">
869 <div class="content">
870 <pre><tt>$ git merge fixes enhancements</tt></pre>
871 </div></div>
872 </li>
873 <li>
875 Merge branch <tt>obsolete</tt> into the current branch, using <tt>ours</tt>
876 merge strategy:
877 </p>
878 <div class="listingblock">
879 <div class="content">
880 <pre><tt>$ git merge -s ours obsolete</tt></pre>
881 </div></div>
882 </li>
883 <li>
885 Merge branch <tt>maint</tt> into the current branch, but do not make
886 a new commit automatically:
887 </p>
888 <div class="listingblock">
889 <div class="content">
890 <pre><tt>$ git merge --no-commit maint</tt></pre>
891 </div></div>
892 <div class="paragraph"><p>This can be used when you want to include further changes to the
893 merge, or want to write your own merge commit message.</p></div>
894 <div class="paragraph"><p>You should refrain from abusing this option to sneak substantial
895 changes into a merge commit. Small fixups like bumping
896 release/version name would be acceptable.</p></div>
897 </li>
898 </ul></div>
899 </div>
900 <h2 id="_merge_strategies">MERGE STRATEGIES</h2>
901 <div class="sectionbody">
902 <div class="paragraph"><p>The merge mechanism (<em>git-merge</em> and <em>git-pull</em> commands) allows the
903 backend <em>merge strategies</em> to be chosen with <tt>-s</tt> option. Some strategies
904 can also take their own options, which can be passed by giving <tt>-X&lt;option&gt;</tt>
905 arguments to <em>git-merge</em> and/or <em>git-pull</em>.</p></div>
906 <div class="dlist"><dl>
907 <dt class="hdlist1">
908 resolve
909 </dt>
910 <dd>
912 This can only resolve two heads (i.e. the current branch
913 and another branch you pulled from) using a 3-way merge
914 algorithm. It tries to carefully detect criss-cross
915 merge ambiguities and is considered generally safe and
916 fast.
917 </p>
918 </dd>
919 <dt class="hdlist1">
920 recursive
921 </dt>
922 <dd>
924 This can only resolve two heads using a 3-way merge
925 algorithm. When there is more than one common
926 ancestor that can be used for 3-way merge, it creates a
927 merged tree of the common ancestors and uses that as
928 the reference tree for the 3-way merge. This has been
929 reported to result in fewer merge conflicts without
930 causing mis-merges by tests done on actual merge commits
931 taken from Linux 2.6 kernel development history.
932 Additionally this can detect and handle merges involving
933 renames. This is the default merge strategy when
934 pulling or merging one branch.
935 </p>
936 <div class="paragraph"><p>The <em>recursive</em> strategy can take the following options:</p></div>
937 <div class="dlist"><dl>
938 <dt class="hdlist1">
939 ours
940 </dt>
941 <dd>
943 This option forces conflicting hunks to be auto-resolved cleanly by
944 favoring <em>our</em> version. Changes from the other tree that do not
945 conflict with our side are reflected to the merge result.
946 </p>
947 <div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
948 even look at what the other tree contains at all. It discards everything
949 the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
950 </dd>
951 <dt class="hdlist1">
952 theirs
953 </dt>
954 <dd>
956 This is opposite of <em>ours</em>.
957 </p>
958 </dd>
959 <dt class="hdlist1">
960 patience
961 </dt>
962 <dd>
964 With this option, <em>merge-recursive</em> spends a little extra time
965 to avoid mismerges that sometimes occur due to unimportant
966 matching lines (e.g., braces from distinct functions). Use
967 this when the branches to be merged have diverged wildly.
968 See also <a href="git-diff.html">git-diff(1)</a> <tt>--patience</tt>.
969 </p>
970 </dd>
971 <dt class="hdlist1">
972 ignore-space-change
973 </dt>
974 <dt class="hdlist1">
975 ignore-all-space
976 </dt>
977 <dt class="hdlist1">
978 ignore-space-at-eol
979 </dt>
980 <dd>
982 Treats lines with the indicated type of whitespace change as
983 unchanged for the sake of a three-way merge. Whitespace
984 changes mixed with other changes to a line are not ignored.
985 See also <a href="git-diff.html">git-diff(1)</a> <tt>-b</tt>, <tt>-w</tt>, and
986 <tt>--ignore-space-at-eol</tt>.
987 </p>
988 <div class="ulist"><ul>
989 <li>
991 If <em>their</em> version only introduces whitespace changes to a line,
992 <em>our</em> version is used;
993 </p>
994 </li>
995 <li>
997 If <em>our</em> version introduces whitespace changes but <em>their</em>
998 version includes a substantial change, <em>their</em> version is used;
999 </p>
1000 </li>
1001 <li>
1003 Otherwise, the merge proceeds in the usual way.
1004 </p>
1005 </li>
1006 </ul></div>
1007 </dd>
1008 <dt class="hdlist1">
1009 renormalize
1010 </dt>
1011 <dd>
1013 This runs a virtual check-out and check-in of all three stages
1014 of a file when resolving a three-way merge. This option is
1015 meant to be used when merging branches with different clean
1016 filters or end-of-line normalization rules. See "Merging
1017 branches with differing checkin/checkout attributes" in
1018 <a href="gitattributes.html">gitattributes(5)</a> for details.
1019 </p>
1020 </dd>
1021 <dt class="hdlist1">
1022 no-renormalize
1023 </dt>
1024 <dd>
1026 Disables the <tt>renormalize</tt> option. This overrides the
1027 <tt>merge.renormalize</tt> configuration variable.
1028 </p>
1029 </dd>
1030 <dt class="hdlist1">
1031 rename-threshold=&lt;n&gt;
1032 </dt>
1033 <dd>
1035 Controls the similarity threshold used for rename detection.
1036 See also <a href="git-diff.html">git-diff(1)</a> <tt>-M</tt>.
1037 </p>
1038 </dd>
1039 <dt class="hdlist1">
1040 subtree[=&lt;path&gt;]
1041 </dt>
1042 <dd>
1044 This option is a more advanced form of <em>subtree</em> strategy, where
1045 the strategy makes a guess on how two trees must be shifted to
1046 match with each other when merging. Instead, the specified path
1047 is prefixed (or stripped from the beginning) to make the shape of
1048 two trees to match.
1049 </p>
1050 </dd>
1051 </dl></div>
1052 </dd>
1053 <dt class="hdlist1">
1054 octopus
1055 </dt>
1056 <dd>
1058 This resolves cases with more than two heads, but refuses to do
1059 a complex merge that needs manual resolution. It is
1060 primarily meant to be used for bundling topic branch
1061 heads together. This is the default merge strategy when
1062 pulling or merging more than one branch.
1063 </p>
1064 </dd>
1065 <dt class="hdlist1">
1066 ours
1067 </dt>
1068 <dd>
1070 This resolves any number of heads, but the resulting tree of the
1071 merge is always that of the current branch head, effectively
1072 ignoring all changes from all other branches. It is meant to
1073 be used to supersede old development history of side
1074 branches. Note that this is different from the -Xours option to
1075 the <em>recursive</em> merge strategy.
1076 </p>
1077 </dd>
1078 <dt class="hdlist1">
1079 subtree
1080 </dt>
1081 <dd>
1083 This is a modified recursive strategy. When merging trees A and
1084 B, if B corresponds to a subtree of A, B is first adjusted to
1085 match the tree structure of A, instead of reading the trees at
1086 the same level. This adjustment is also done to the common
1087 ancestor tree.
1088 </p>
1089 </dd>
1090 </dl></div>
1091 </div>
1092 <h2 id="_configuration">CONFIGURATION</h2>
1093 <div class="sectionbody">
1094 <div class="dlist"><dl>
1095 <dt class="hdlist1">
1096 merge.conflictstyle
1097 </dt>
1098 <dd>
1100 Specify the style in which conflicted hunks are written out to
1101 working tree files upon merge. The default is "merge", which
1102 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
1103 a <tt>=======</tt> marker, changes made by the other side, and then
1104 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
1105 marker and the original text before the <tt>=======</tt> marker.
1106 </p>
1107 </dd>
1108 <dt class="hdlist1">
1109 merge.log
1110 </dt>
1111 <dd>
1113 In addition to branch names, populate the log message with at
1114 most the specified number of one-line descriptions from the
1115 actual commits that are being merged. Defaults to false, and
1116 true is a synonym for 20.
1117 </p>
1118 </dd>
1119 <dt class="hdlist1">
1120 merge.renameLimit
1121 </dt>
1122 <dd>
1124 The number of files to consider when performing rename detection
1125 during a merge; if not specified, defaults to the value of
1126 diff.renameLimit.
1127 </p>
1128 </dd>
1129 <dt class="hdlist1">
1130 merge.renormalize
1131 </dt>
1132 <dd>
1134 Tell git that canonical representation of files in the
1135 repository has changed over time (e.g. earlier commits record
1136 text files with CRLF line endings, but recent ones use LF line
1137 endings). In such a repository, git can convert the data
1138 recorded in commits to a canonical form before performing a
1139 merge to reduce unnecessary conflicts. For more information,
1140 see section "Merging branches with differing checkin/checkout
1141 attributes" in <a href="gitattributes.html">gitattributes(5)</a>.
1142 </p>
1143 </dd>
1144 <dt class="hdlist1">
1145 merge.stat
1146 </dt>
1147 <dd>
1149 Whether to print the diffstat between ORIG_HEAD and the merge result
1150 at the end of the merge. True by default.
1151 </p>
1152 </dd>
1153 <dt class="hdlist1">
1154 merge.tool
1155 </dt>
1156 <dd>
1158 Controls which merge resolution program is used by
1159 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "kdiff3",
1160 "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff",
1161 "diffuse", "ecmerge", "tortoisemerge", "p4merge", "araxis" and
1162 "opendiff". Any other value is treated is custom merge tool
1163 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
1164 </p>
1165 </dd>
1166 <dt class="hdlist1">
1167 merge.verbosity
1168 </dt>
1169 <dd>
1171 Controls the amount of output shown by the recursive merge
1172 strategy. Level 0 outputs nothing except a final error
1173 message if conflicts were detected. Level 1 outputs only
1174 conflicts, 2 outputs conflicts and file changes. Level 5 and
1175 above outputs debugging information. The default is level 2.
1176 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
1177 </p>
1178 </dd>
1179 <dt class="hdlist1">
1180 merge.&lt;driver&gt;.name
1181 </dt>
1182 <dd>
1184 Defines a human-readable name for a custom low-level
1185 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1186 </p>
1187 </dd>
1188 <dt class="hdlist1">
1189 merge.&lt;driver&gt;.driver
1190 </dt>
1191 <dd>
1193 Defines the command that implements a custom low-level
1194 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1195 </p>
1196 </dd>
1197 <dt class="hdlist1">
1198 merge.&lt;driver&gt;.recursive
1199 </dt>
1200 <dd>
1202 Names a low-level merge driver to be used when
1203 performing an internal merge between common ancestors.
1204 See <a href="gitattributes.html">gitattributes(5)</a> for details.
1205 </p>
1206 </dd>
1207 <dt class="hdlist1">
1208 branch.&lt;name&gt;.mergeoptions
1209 </dt>
1210 <dd>
1212 Sets default options for merging into branch &lt;name&gt;. The syntax and
1213 supported options are the same as those of <em>git merge</em>, but option
1214 values containing whitespace characters are currently not supported.
1215 </p>
1216 </dd>
1217 </dl></div>
1218 </div>
1219 <h2 id="_see_also">SEE ALSO</h2>
1220 <div class="sectionbody">
1221 <div class="paragraph"><p><a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>, <a href="git-pull.html">git-pull(1)</a>,
1222 <a href="gitattributes.html">gitattributes(5)</a>,
1223 <a href="git-reset.html">git-reset(1)</a>,
1224 <a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1225 <a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
1226 <a href="git-mergetool.html">git-mergetool(1)</a></p></div>
1227 </div>
1228 <h2 id="_author">Author</h2>
1229 <div class="sectionbody">
1230 <div class="paragraph"><p>Written by Junio C Hamano &lt;<a href="mailto:gitster@pobox.com">gitster@pobox.com</a>&gt;</p></div>
1231 </div>
1232 <h2 id="_documentation">Documentation</h2>
1233 <div class="sectionbody">
1234 <div class="paragraph"><p>Documentation by Junio C Hamano and the git-list &lt;<a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>&gt;.</p></div>
1235 </div>
1236 <h2 id="_git">GIT</h2>
1237 <div class="sectionbody">
1238 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1239 </div>
1240 <div id="footer">
1241 <div id="footer-text">
1242 Last updated 2010-12-08 22:49:27 UTC
1243 </div>
1244 </div>
1245 </body>
1246 </html>