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