Autogenerated HTML docs for v1.7.4.2-414-g07514
[git/jnareb-git.git] / git-merge.html
blob1c2bfe537c4cf309dacc61b758228eaeb29415af
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. Implies --no-progress.
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 --progress
624 </dt>
625 <dt class="hdlist1">
626 --no-progress
627 </dt>
628 <dd>
630 Turn progress on/off explicitly. If neither is specified,
631 progress is shown if standard error is connected to a terminal.
632 Note that not all merge strategies may support progress
633 reporting.
634 </p>
635 </dd>
636 <dt class="hdlist1">
637 -m &lt;msg&gt;
638 </dt>
639 <dd>
641 Set the commit message to be used for the merge commit (in
642 case one is created).
643 </p>
644 <div class="paragraph"><p>If <tt>--log</tt> is specified, a shortlog of the commits being merged
645 will be appended to the specified message.</p></div>
646 <div class="paragraph"><p>The <em>git fmt-merge-msg</em> command can be
647 used to give a good default for automated <em>git merge</em>
648 invocations.</p></div>
649 </dd>
650 <dt class="hdlist1">
651 --rerere-autoupdate
652 </dt>
653 <dt class="hdlist1">
654 --no-rerere-autoupdate
655 </dt>
656 <dd>
658 Allow the rerere mechanism to update the index with the
659 result of auto-conflict resolution if possible.
660 </p>
661 </dd>
662 <dt class="hdlist1">
663 --abort
664 </dt>
665 <dd>
667 Abort the current conflict resolution process, and
668 try to reconstruct the pre-merge state.
669 </p>
670 <div class="paragraph"><p>If there were uncommitted worktree changes present when the merge
671 started, <em>git merge --abort</em> will in some cases be unable to
672 reconstruct these changes. It is therefore recommended to always
673 commit or stash your changes before running <em>git merge</em>.</p></div>
674 <div class="paragraph"><p><em>git merge --abort</em> is equivalent to <em>git reset --merge</em> when
675 <tt>MERGE_HEAD</tt> is present.</p></div>
676 </dd>
677 <dt class="hdlist1">
678 &lt;commit&gt;&#8230;
679 </dt>
680 <dd>
682 Commits, usually other branch heads, to merge into our branch.
683 You need at least one &lt;commit&gt;. Specifying more than one
684 &lt;commit&gt; obviously means you are trying an Octopus.
685 </p>
686 </dd>
687 </dl></div>
688 </div>
689 <h2 id="_pre_merge_checks">PRE-MERGE CHECKS</h2>
690 <div class="sectionbody">
691 <div class="paragraph"><p>Before applying outside changes, you should get your own work in
692 good shape and committed locally, so it will not be clobbered if
693 there are conflicts. See also <a href="git-stash.html">git-stash(1)</a>.
694 <em>git pull</em> and <em>git merge</em> will stop without doing anything when
695 local uncommitted changes overlap with files that <em>git pull</em>/<em>git
696 merge</em> may need to update.</p></div>
697 <div class="paragraph"><p>To avoid recording unrelated changes in the merge commit,
698 <em>git pull</em> and <em>git merge</em> will also abort if there are any changes
699 registered in the index relative to the <tt>HEAD</tt> commit. (One
700 exception is when the changed index entries are in the state that
701 would result from the merge already.)</p></div>
702 <div class="paragraph"><p>If all named commits are already ancestors of <tt>HEAD</tt>, <em>git merge</em>
703 will exit early with the message "Already up-to-date."</p></div>
704 </div>
705 <h2 id="_fast_forward_merge">FAST-FORWARD MERGE</h2>
706 <div class="sectionbody">
707 <div class="paragraph"><p>Often the current branch head is an ancestor of the named commit.
708 This is the most common case especially when invoked from <em>git
709 pull</em>: you are tracking an upstream repository, you have committed
710 no local changes, and now you want to update to a newer upstream
711 revision. In this case, a new commit is not needed to store the
712 combined history; instead, the <tt>HEAD</tt> (along with the index) is
713 updated to point at the named commit, without creating an extra
714 merge commit.</p></div>
715 <div class="paragraph"><p>This behavior can be suppressed with the <tt>--no-ff</tt> option.</p></div>
716 </div>
717 <h2 id="_true_merge">TRUE MERGE</h2>
718 <div class="sectionbody">
719 <div class="paragraph"><p>Except in a fast-forward merge (see above), the branches to be
720 merged must be tied together by a merge commit that has both of them
721 as its parents.</p></div>
722 <div class="paragraph"><p>A merged version reconciling the changes from all branches to be
723 merged is committed, and your <tt>HEAD</tt>, index, and working tree are
724 updated to it. It is possible to have modifications in the working
725 tree as long as they do not overlap; the update will preserve them.</p></div>
726 <div class="paragraph"><p>When it is not obvious how to reconcile the changes, the following
727 happens:</p></div>
728 <div class="olist arabic"><ol class="arabic">
729 <li>
731 The <tt>HEAD</tt> pointer stays the same.
732 </p>
733 </li>
734 <li>
736 The <tt>MERGE_HEAD</tt> ref is set to point to the other branch head.
737 </p>
738 </li>
739 <li>
741 Paths that merged cleanly are updated both in the index file and
742 in your working tree.
743 </p>
744 </li>
745 <li>
747 For conflicting paths, the index file records up to three
748 versions: stage 1 stores the version from the common ancestor,
749 stage 2 from <tt>HEAD</tt>, and stage 3 from <tt>MERGE_HEAD</tt> (you
750 can inspect the stages with <tt>git ls-files -u</tt>). The working
751 tree files contain the result of the "merge" program; i.e. 3-way
752 merge results with familiar conflict markers <tt>&lt;&lt;&lt;</tt> <tt>===</tt> <tt>&gt;&gt;&gt;</tt>.
753 </p>
754 </li>
755 <li>
757 No other changes are made. In particular, the local
758 modifications you had before you started merge will stay the
759 same and the index entries for them stay as they were,
760 i.e. matching <tt>HEAD</tt>.
761 </p>
762 </li>
763 </ol></div>
764 <div class="paragraph"><p>If you tried a merge which resulted in complex conflicts and
765 want to start over, you can recover with <tt>git merge --abort</tt>.</p></div>
766 </div>
767 <h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
768 <div class="sectionbody">
769 <div class="paragraph"><p>During a merge, the working tree files are updated to reflect the result
770 of the merge. Among the changes made to the common ancestor&#8217;s version,
771 non-overlapping ones (that is, you changed an area of the file while the
772 other side left that area intact, or vice versa) are incorporated in the
773 final result verbatim. When both sides made changes to the same area,
774 however, git cannot randomly pick one side over the other, and asks you to
775 resolve it by leaving what both sides did to that area.</p></div>
776 <div class="paragraph"><p>By default, git uses the same style as that is used by "merge" program
777 from the RCS suite to present such a conflicted hunk, like this:</p></div>
778 <div class="listingblock">
779 <div class="content">
780 <pre><tt>Here are lines that are either unchanged from the common
781 ancestor, or cleanly resolved because only one side changed.
782 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
783 Conflict resolution is hard;
784 let's go shopping.
785 =======
786 Git makes conflict resolution easy.
787 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
788 And here is another line that is cleanly resolved or unmodified.</tt></pre>
789 </div></div>
790 <div class="paragraph"><p>The area where a pair of conflicting changes happened is marked with markers
791 <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>
792 is typically your side, and the part afterwards is typically their side.</p></div>
793 <div class="paragraph"><p>The default format does not show what the original said in the conflicting
794 area. You cannot tell how many lines are deleted and replaced with
795 Barbie&#8217;s remark on your side. The only thing you can tell is that your
796 side wants to say it is hard and you&#8217;d prefer to go shopping, while the
797 other side wants to claim it is easy.</p></div>
798 <div class="paragraph"><p>An alternative style can be used by setting the "merge.conflictstyle"
799 configuration variable to "diff3". In "diff3" style, the above conflict
800 may look like this:</p></div>
801 <div class="listingblock">
802 <div class="content">
803 <pre><tt>Here are lines that are either unchanged from the common
804 ancestor, or cleanly resolved because only one side changed.
805 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
806 Conflict resolution is hard;
807 let's go shopping.
808 |||||||
809 Conflict resolution is hard.
810 =======
811 Git makes conflict resolution easy.
812 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
813 And here is another line that is cleanly resolved or unmodified.</tt></pre>
814 </div></div>
815 <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
816 another <tt>|||||||</tt> marker that is followed by the original text. You can
817 tell that the original just stated a fact, and your side simply gave in to
818 that statement and gave up, while the other side tried to have a more
819 positive attitude. You can sometimes come up with a better resolution by
820 viewing the original.</p></div>
821 </div>
822 <h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
823 <div class="sectionbody">
824 <div class="paragraph"><p>After seeing a conflict, you can do two things:</p></div>
825 <div class="ulist"><ul>
826 <li>
828 Decide not to merge. The only clean-ups you need are to reset
829 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
830 up working tree changes made by 2. and 3.; <tt>git merge --abort</tt>
831 can be used for this.
832 </p>
833 </li>
834 <li>
836 Resolve the conflicts. Git will mark the conflicts in
837 the working tree. Edit the files into shape and
838 <em>git add</em> them to the index. Use <em>git commit</em> to seal the deal.
839 </p>
840 </li>
841 </ul></div>
842 <div class="paragraph"><p>You can work through the conflict with a number of tools:</p></div>
843 <div class="ulist"><ul>
844 <li>
846 Use a mergetool. <tt>git mergetool</tt> to launch a graphical
847 mergetool which will work you through the merge.
848 </p>
849 </li>
850 <li>
852 Look at the diffs. <tt>git diff</tt> will show a three-way diff,
853 highlighting changes from both the <tt>HEAD</tt> and <tt>MERGE_HEAD</tt>
854 versions.
855 </p>
856 </li>
857 <li>
859 Look at the diffs from each branch. <tt>git log --merge -p &lt;path&gt;</tt>
860 will show diffs first for the <tt>HEAD</tt> version and then the
861 <tt>MERGE_HEAD</tt> version.
862 </p>
863 </li>
864 <li>
866 Look at the originals. <tt>git show :1:filename</tt> shows the
867 common ancestor, <tt>git show :2:filename</tt> shows the <tt>HEAD</tt>
868 version, and <tt>git show :3:filename</tt> shows the <tt>MERGE_HEAD</tt>
869 version.
870 </p>
871 </li>
872 </ul></div>
873 </div>
874 <h2 id="_examples">EXAMPLES</h2>
875 <div class="sectionbody">
876 <div class="ulist"><ul>
877 <li>
879 Merge branches <tt>fixes</tt> and <tt>enhancements</tt> on top of
880 the current branch, making an octopus merge:
881 </p>
882 <div class="listingblock">
883 <div class="content">
884 <pre><tt>$ git merge fixes enhancements</tt></pre>
885 </div></div>
886 </li>
887 <li>
889 Merge branch <tt>obsolete</tt> into the current branch, using <tt>ours</tt>
890 merge strategy:
891 </p>
892 <div class="listingblock">
893 <div class="content">
894 <pre><tt>$ git merge -s ours obsolete</tt></pre>
895 </div></div>
896 </li>
897 <li>
899 Merge branch <tt>maint</tt> into the current branch, but do not make
900 a new commit automatically:
901 </p>
902 <div class="listingblock">
903 <div class="content">
904 <pre><tt>$ git merge --no-commit maint</tt></pre>
905 </div></div>
906 <div class="paragraph"><p>This can be used when you want to include further changes to the
907 merge, or want to write your own merge commit message.</p></div>
908 <div class="paragraph"><p>You should refrain from abusing this option to sneak substantial
909 changes into a merge commit. Small fixups like bumping
910 release/version name would be acceptable.</p></div>
911 </li>
912 </ul></div>
913 </div>
914 <h2 id="_merge_strategies">MERGE STRATEGIES</h2>
915 <div class="sectionbody">
916 <div class="paragraph"><p>The merge mechanism (<em>git-merge</em> and <em>git-pull</em> commands) allows the
917 backend <em>merge strategies</em> to be chosen with <tt>-s</tt> option. Some strategies
918 can also take their own options, which can be passed by giving <tt>-X&lt;option&gt;</tt>
919 arguments to <em>git-merge</em> and/or <em>git-pull</em>.</p></div>
920 <div class="dlist"><dl>
921 <dt class="hdlist1">
922 resolve
923 </dt>
924 <dd>
926 This can only resolve two heads (i.e. the current branch
927 and another branch you pulled from) using a 3-way merge
928 algorithm. It tries to carefully detect criss-cross
929 merge ambiguities and is considered generally safe and
930 fast.
931 </p>
932 </dd>
933 <dt class="hdlist1">
934 recursive
935 </dt>
936 <dd>
938 This can only resolve two heads using a 3-way merge
939 algorithm. When there is more than one common
940 ancestor that can be used for 3-way merge, it creates a
941 merged tree of the common ancestors and uses that as
942 the reference tree for the 3-way merge. This has been
943 reported to result in fewer merge conflicts without
944 causing mis-merges by tests done on actual merge commits
945 taken from Linux 2.6 kernel development history.
946 Additionally this can detect and handle merges involving
947 renames. This is the default merge strategy when
948 pulling or merging one branch.
949 </p>
950 <div class="paragraph"><p>The <em>recursive</em> strategy can take the following options:</p></div>
951 <div class="dlist"><dl>
952 <dt class="hdlist1">
953 ours
954 </dt>
955 <dd>
957 This option forces conflicting hunks to be auto-resolved cleanly by
958 favoring <em>our</em> version. Changes from the other tree that do not
959 conflict with our side are reflected to the merge result.
960 </p>
961 <div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
962 even look at what the other tree contains at all. It discards everything
963 the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
964 </dd>
965 <dt class="hdlist1">
966 theirs
967 </dt>
968 <dd>
970 This is opposite of <em>ours</em>.
971 </p>
972 </dd>
973 <dt class="hdlist1">
974 patience
975 </dt>
976 <dd>
978 With this option, <em>merge-recursive</em> spends a little extra time
979 to avoid mismerges that sometimes occur due to unimportant
980 matching lines (e.g., braces from distinct functions). Use
981 this when the branches to be merged have diverged wildly.
982 See also <a href="git-diff.html">git-diff(1)</a> <tt>--patience</tt>.
983 </p>
984 </dd>
985 <dt class="hdlist1">
986 ignore-space-change
987 </dt>
988 <dt class="hdlist1">
989 ignore-all-space
990 </dt>
991 <dt class="hdlist1">
992 ignore-space-at-eol
993 </dt>
994 <dd>
996 Treats lines with the indicated type of whitespace change as
997 unchanged for the sake of a three-way merge. Whitespace
998 changes mixed with other changes to a line are not ignored.
999 See also <a href="git-diff.html">git-diff(1)</a> <tt>-b</tt>, <tt>-w</tt>, and
1000 <tt>--ignore-space-at-eol</tt>.
1001 </p>
1002 <div class="ulist"><ul>
1003 <li>
1005 If <em>their</em> version only introduces whitespace changes to a line,
1006 <em>our</em> version is used;
1007 </p>
1008 </li>
1009 <li>
1011 If <em>our</em> version introduces whitespace changes but <em>their</em>
1012 version includes a substantial change, <em>their</em> version is used;
1013 </p>
1014 </li>
1015 <li>
1017 Otherwise, the merge proceeds in the usual way.
1018 </p>
1019 </li>
1020 </ul></div>
1021 </dd>
1022 <dt class="hdlist1">
1023 renormalize
1024 </dt>
1025 <dd>
1027 This runs a virtual check-out and check-in of all three stages
1028 of a file when resolving a three-way merge. This option is
1029 meant to be used when merging branches with different clean
1030 filters or end-of-line normalization rules. See "Merging
1031 branches with differing checkin/checkout attributes" in
1032 <a href="gitattributes.html">gitattributes(5)</a> for details.
1033 </p>
1034 </dd>
1035 <dt class="hdlist1">
1036 no-renormalize
1037 </dt>
1038 <dd>
1040 Disables the <tt>renormalize</tt> option. This overrides the
1041 <tt>merge.renormalize</tt> configuration variable.
1042 </p>
1043 </dd>
1044 <dt class="hdlist1">
1045 rename-threshold=&lt;n&gt;
1046 </dt>
1047 <dd>
1049 Controls the similarity threshold used for rename detection.
1050 See also <a href="git-diff.html">git-diff(1)</a> <tt>-M</tt>.
1051 </p>
1052 </dd>
1053 <dt class="hdlist1">
1054 subtree[=&lt;path&gt;]
1055 </dt>
1056 <dd>
1058 This option is a more advanced form of <em>subtree</em> strategy, where
1059 the strategy makes a guess on how two trees must be shifted to
1060 match with each other when merging. Instead, the specified path
1061 is prefixed (or stripped from the beginning) to make the shape of
1062 two trees to match.
1063 </p>
1064 </dd>
1065 </dl></div>
1066 </dd>
1067 <dt class="hdlist1">
1068 octopus
1069 </dt>
1070 <dd>
1072 This resolves cases with more than two heads, but refuses to do
1073 a complex merge that needs manual resolution. It is
1074 primarily meant to be used for bundling topic branch
1075 heads together. This is the default merge strategy when
1076 pulling or merging more than one branch.
1077 </p>
1078 </dd>
1079 <dt class="hdlist1">
1080 ours
1081 </dt>
1082 <dd>
1084 This resolves any number of heads, but the resulting tree of the
1085 merge is always that of the current branch head, effectively
1086 ignoring all changes from all other branches. It is meant to
1087 be used to supersede old development history of side
1088 branches. Note that this is different from the -Xours option to
1089 the <em>recursive</em> merge strategy.
1090 </p>
1091 </dd>
1092 <dt class="hdlist1">
1093 subtree
1094 </dt>
1095 <dd>
1097 This is a modified recursive strategy. When merging trees A and
1098 B, if B corresponds to a subtree of A, B is first adjusted to
1099 match the tree structure of A, instead of reading the trees at
1100 the same level. This adjustment is also done to the common
1101 ancestor tree.
1102 </p>
1103 </dd>
1104 </dl></div>
1105 </div>
1106 <h2 id="_configuration">CONFIGURATION</h2>
1107 <div class="sectionbody">
1108 <div class="dlist"><dl>
1109 <dt class="hdlist1">
1110 merge.conflictstyle
1111 </dt>
1112 <dd>
1114 Specify the style in which conflicted hunks are written out to
1115 working tree files upon merge. The default is "merge", which
1116 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
1117 a <tt>=======</tt> marker, changes made by the other side, and then
1118 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
1119 marker and the original text before the <tt>=======</tt> marker.
1120 </p>
1121 </dd>
1122 <dt class="hdlist1">
1123 merge.log
1124 </dt>
1125 <dd>
1127 In addition to branch names, populate the log message with at
1128 most the specified number of one-line descriptions from the
1129 actual commits that are being merged. Defaults to false, and
1130 true is a synonym for 20.
1131 </p>
1132 </dd>
1133 <dt class="hdlist1">
1134 merge.renameLimit
1135 </dt>
1136 <dd>
1138 The number of files to consider when performing rename detection
1139 during a merge; if not specified, defaults to the value of
1140 diff.renameLimit.
1141 </p>
1142 </dd>
1143 <dt class="hdlist1">
1144 merge.renormalize
1145 </dt>
1146 <dd>
1148 Tell git that canonical representation of files in the
1149 repository has changed over time (e.g. earlier commits record
1150 text files with CRLF line endings, but recent ones use LF line
1151 endings). In such a repository, git can convert the data
1152 recorded in commits to a canonical form before performing a
1153 merge to reduce unnecessary conflicts. For more information,
1154 see section "Merging branches with differing checkin/checkout
1155 attributes" in <a href="gitattributes.html">gitattributes(5)</a>.
1156 </p>
1157 </dd>
1158 <dt class="hdlist1">
1159 merge.stat
1160 </dt>
1161 <dd>
1163 Whether to print the diffstat between ORIG_HEAD and the merge result
1164 at the end of the merge. True by default.
1165 </p>
1166 </dd>
1167 <dt class="hdlist1">
1168 merge.tool
1169 </dt>
1170 <dd>
1172 Controls which merge resolution program is used by
1173 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "araxis",
1174 "bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
1175 "opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
1176 and "xxdiff". Any other value is treated is custom merge tool
1177 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
1178 </p>
1179 </dd>
1180 <dt class="hdlist1">
1181 merge.verbosity
1182 </dt>
1183 <dd>
1185 Controls the amount of output shown by the recursive merge
1186 strategy. Level 0 outputs nothing except a final error
1187 message if conflicts were detected. Level 1 outputs only
1188 conflicts, 2 outputs conflicts and file changes. Level 5 and
1189 above outputs debugging information. The default is level 2.
1190 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
1191 </p>
1192 </dd>
1193 <dt class="hdlist1">
1194 merge.&lt;driver&gt;.name
1195 </dt>
1196 <dd>
1198 Defines a human-readable name for a custom low-level
1199 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1200 </p>
1201 </dd>
1202 <dt class="hdlist1">
1203 merge.&lt;driver&gt;.driver
1204 </dt>
1205 <dd>
1207 Defines the command that implements a custom low-level
1208 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1209 </p>
1210 </dd>
1211 <dt class="hdlist1">
1212 merge.&lt;driver&gt;.recursive
1213 </dt>
1214 <dd>
1216 Names a low-level merge driver to be used when
1217 performing an internal merge between common ancestors.
1218 See <a href="gitattributes.html">gitattributes(5)</a> for details.
1219 </p>
1220 </dd>
1221 <dt class="hdlist1">
1222 branch.&lt;name&gt;.mergeoptions
1223 </dt>
1224 <dd>
1226 Sets default options for merging into branch &lt;name&gt;. The syntax and
1227 supported options are the same as those of <em>git merge</em>, but option
1228 values containing whitespace characters are currently not supported.
1229 </p>
1230 </dd>
1231 </dl></div>
1232 </div>
1233 <h2 id="_see_also">SEE ALSO</h2>
1234 <div class="sectionbody">
1235 <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>,
1236 <a href="gitattributes.html">gitattributes(5)</a>,
1237 <a href="git-reset.html">git-reset(1)</a>,
1238 <a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1239 <a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
1240 <a href="git-mergetool.html">git-mergetool(1)</a></p></div>
1241 </div>
1242 <h2 id="_git">GIT</h2>
1243 <div class="sectionbody">
1244 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1245 </div>
1246 <div id="footer">
1247 <div id="footer-text">
1248 Last updated 2011-03-15 23:30:14 UTC
1249 </div>
1250 </div>
1251 </body>
1252 </html>