Autogenerated HTML docs for v1.7.7-419-g87009
[git/jnareb-git.git] / git-merge.html
blob6d0029174e98efe1fcfed1d6047f75558790be1a
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.5.2" />
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.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 git-merge(1) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>git-merge -
578 Join two or more development histories together
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="verseblock">
586 <div class="verseblock-content"><em>git merge</em> [-n] [--stat] [--no-commit] [--squash]
587 [-s &lt;strategy&gt;] [-X &lt;strategy-option&gt;]
588 [--[no-]rerere-autoupdate] [-m &lt;msg&gt;] [&lt;commit&gt;&#8230;]
589 <em>git merge</em> &lt;msg&gt; HEAD &lt;commit&gt;&#8230;
590 <em>git merge</em> --abort</div>
591 <div class="verseblock-attribution">
592 </div></div>
593 </div>
594 <h2 id="_description">DESCRIPTION</h2>
595 <div class="sectionbody">
596 <div class="paragraph"><p>Incorporates changes from the named commits (since the time their
597 histories diverged from the current branch) into the current
598 branch. This command is used by <em>git pull</em> to incorporate changes
599 from another repository and can be used by hand to merge changes
600 from one branch into another.</p></div>
601 <div class="paragraph"><p>Assume the following history exists and the current branch is
602 "<tt>master</tt>":</p></div>
603 <div class="listingblock">
604 <div class="content">
605 <pre><tt> A---B---C topic
607 D---E---F---G master</tt></pre>
608 </div></div>
609 <div class="paragraph"><p>Then "<tt>git merge topic</tt>" will replay the changes made on the
610 <tt>topic</tt> branch since it diverged from <tt>master</tt> (i.e., <tt>E</tt>) until
611 its current commit (<tt>C</tt>) on top of <tt>master</tt>, and record the result
612 in a new commit along with the names of the two parent commits and
613 a log message from the user describing the changes.</p></div>
614 <div class="listingblock">
615 <div class="content">
616 <pre><tt> A---B---C topic
618 D---E---F---G---H master</tt></pre>
619 </div></div>
620 <div class="paragraph"><p>The second syntax (&lt;msg&gt; <tt>HEAD</tt> &lt;commit&gt;&#8230;) is supported for
621 historical reasons. Do not use it from the command line or in
622 new scripts. It is the same as <tt>git merge -m &lt;msg&gt; &lt;commit&gt;&#8230;</tt>.</p></div>
623 <div class="paragraph"><p>The third syntax ("<tt>git merge --abort</tt>") can only be run after the
624 merge has resulted in conflicts. <em>git merge --abort</em> will abort the
625 merge process and try to reconstruct the pre-merge state. However,
626 if there were uncommitted changes when the merge started (and
627 especially if those changes were further modified after the merge
628 was started), <em>git merge --abort</em> will in some cases be unable to
629 reconstruct the original (pre-merge) changes. Therefore:</p></div>
630 <div class="paragraph"><p><strong>Warning</strong>: Running <em>git merge</em> with uncommitted changes is
631 discouraged: while possible, it leaves you in a state that is hard to
632 back out of in the case of a conflict.</p></div>
633 </div>
634 <h2 id="_options">OPTIONS</h2>
635 <div class="sectionbody">
636 <div class="dlist"><dl>
637 <dt class="hdlist1">
638 --commit
639 </dt>
640 <dt class="hdlist1">
641 --no-commit
642 </dt>
643 <dd>
645 Perform the merge and commit the result. This option can
646 be used to override --no-commit.
647 </p>
648 <div class="paragraph"><p>With --no-commit perform the merge but pretend the merge
649 failed and do not autocommit, to give the user a chance to
650 inspect and further tweak the merge result before committing.</p></div>
651 </dd>
652 <dt class="hdlist1">
653 --edit
654 </dt>
655 <dt class="hdlist1">
657 </dt>
658 <dd>
659 <div class="literalblock">
660 <div class="content">
661 <pre><tt>Invoke editor before committing successful merge to further
662 edit the default merge message.</tt></pre>
663 </div></div>
664 </dd>
665 <dt class="hdlist1">
666 --ff
667 </dt>
668 <dt class="hdlist1">
669 --no-ff
670 </dt>
671 <dd>
673 Do not generate a merge commit if the merge resolved as
674 a fast-forward, only update the branch pointer. This is
675 the default behavior of git-merge.
676 </p>
677 <div class="paragraph"><p>With --no-ff Generate a merge commit even if the merge
678 resolved as a fast-forward.</p></div>
679 </dd>
680 <dt class="hdlist1">
681 --log[=&lt;n&gt;]
682 </dt>
683 <dt class="hdlist1">
684 --no-log
685 </dt>
686 <dd>
688 In addition to branch names, populate the log message with
689 one-line descriptions from at most &lt;n&gt; actual commits that are being
690 merged. See also <a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>.
691 </p>
692 <div class="paragraph"><p>With --no-log do not list one-line descriptions from the
693 actual commits being merged.</p></div>
694 </dd>
695 <dt class="hdlist1">
696 --stat
697 </dt>
698 <dt class="hdlist1">
700 </dt>
701 <dt class="hdlist1">
702 --no-stat
703 </dt>
704 <dd>
706 Show a diffstat at the end of the merge. The diffstat is also
707 controlled by the configuration option merge.stat.
708 </p>
709 <div class="paragraph"><p>With -n or --no-stat do not show a diffstat at the end of the
710 merge.</p></div>
711 </dd>
712 <dt class="hdlist1">
713 --squash
714 </dt>
715 <dt class="hdlist1">
716 --no-squash
717 </dt>
718 <dd>
720 Produce the working tree and index state as if a real
721 merge happened (except for the merge information),
722 but do not actually make a commit or
723 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
724 cause the next <tt>git commit</tt> command to create a merge
725 commit. This allows you to create a single commit on
726 top of the current branch whose effect is the same as
727 merging another branch (or more in case of an octopus).
728 </p>
729 <div class="paragraph"><p>With --no-squash perform the merge and commit the result. This
730 option can be used to override --squash.</p></div>
731 </dd>
732 <dt class="hdlist1">
733 --ff-only
734 </dt>
735 <dd>
737 Refuse to merge and exit with a non-zero status unless the
738 current <tt>HEAD</tt> is already up-to-date or the merge can be
739 resolved as a fast-forward.
740 </p>
741 </dd>
742 <dt class="hdlist1">
743 -s &lt;strategy&gt;
744 </dt>
745 <dt class="hdlist1">
746 --strategy=&lt;strategy&gt;
747 </dt>
748 <dd>
750 Use the given merge strategy; can be supplied more than
751 once to specify them in the order they should be tried.
752 If there is no <tt>-s</tt> option, a built-in list of strategies
753 is used instead (<em>git merge-recursive</em> when merging a single
754 head, <em>git merge-octopus</em> otherwise).
755 </p>
756 </dd>
757 <dt class="hdlist1">
758 -X &lt;option&gt;
759 </dt>
760 <dt class="hdlist1">
761 --strategy-option=&lt;option&gt;
762 </dt>
763 <dd>
765 Pass merge strategy specific option through to the merge
766 strategy.
767 </p>
768 </dd>
769 <dt class="hdlist1">
770 --summary
771 </dt>
772 <dt class="hdlist1">
773 --no-summary
774 </dt>
775 <dd>
777 Synonyms to --stat and --no-stat; these are deprecated and will be
778 removed in the future.
779 </p>
780 </dd>
781 <dt class="hdlist1">
783 </dt>
784 <dt class="hdlist1">
785 --quiet
786 </dt>
787 <dd>
789 Operate quietly. Implies --no-progress.
790 </p>
791 </dd>
792 <dt class="hdlist1">
794 </dt>
795 <dt class="hdlist1">
796 --verbose
797 </dt>
798 <dd>
800 Be verbose.
801 </p>
802 </dd>
803 <dt class="hdlist1">
804 --progress
805 </dt>
806 <dt class="hdlist1">
807 --no-progress
808 </dt>
809 <dd>
811 Turn progress on/off explicitly. If neither is specified,
812 progress is shown if standard error is connected to a terminal.
813 Note that not all merge strategies may support progress
814 reporting.
815 </p>
816 </dd>
817 <dt class="hdlist1">
818 -m &lt;msg&gt;
819 </dt>
820 <dd>
822 Set the commit message to be used for the merge commit (in
823 case one is created).
824 </p>
825 <div class="paragraph"><p>If <tt>--log</tt> is specified, a shortlog of the commits being merged
826 will be appended to the specified message.</p></div>
827 <div class="paragraph"><p>The <em>git fmt-merge-msg</em> command can be
828 used to give a good default for automated <em>git merge</em>
829 invocations.</p></div>
830 </dd>
831 <dt class="hdlist1">
832 --rerere-autoupdate
833 </dt>
834 <dt class="hdlist1">
835 --no-rerere-autoupdate
836 </dt>
837 <dd>
839 Allow the rerere mechanism to update the index with the
840 result of auto-conflict resolution if possible.
841 </p>
842 </dd>
843 <dt class="hdlist1">
844 --abort
845 </dt>
846 <dd>
848 Abort the current conflict resolution process, and
849 try to reconstruct the pre-merge state.
850 </p>
851 <div class="paragraph"><p>If there were uncommitted worktree changes present when the merge
852 started, <em>git merge --abort</em> will in some cases be unable to
853 reconstruct these changes. It is therefore recommended to always
854 commit or stash your changes before running <em>git merge</em>.</p></div>
855 <div class="paragraph"><p><em>git merge --abort</em> is equivalent to <em>git reset --merge</em> when
856 <tt>MERGE_HEAD</tt> is present.</p></div>
857 </dd>
858 <dt class="hdlist1">
859 &lt;commit&gt;&#8230;
860 </dt>
861 <dd>
863 Commits, usually other branch heads, to merge into our branch.
864 Specifying more than one commit will create a merge with
865 more than two parents (affectionately called an Octopus merge).
866 </p>
867 <div class="paragraph"><p>If no commit is given from the command line, and if <tt>merge.defaultToUpstream</tt>
868 configuration variable is set, merge the remote tracking branches
869 that the current branch is configured to use as its upstream.
870 See also the configuration section of this manual page.</p></div>
871 </dd>
872 </dl></div>
873 </div>
874 <h2 id="_pre_merge_checks">PRE-MERGE CHECKS</h2>
875 <div class="sectionbody">
876 <div class="paragraph"><p>Before applying outside changes, you should get your own work in
877 good shape and committed locally, so it will not be clobbered if
878 there are conflicts. See also <a href="git-stash.html">git-stash(1)</a>.
879 <em>git pull</em> and <em>git merge</em> will stop without doing anything when
880 local uncommitted changes overlap with files that <em>git pull</em>/<em>git
881 merge</em> may need to update.</p></div>
882 <div class="paragraph"><p>To avoid recording unrelated changes in the merge commit,
883 <em>git pull</em> and <em>git merge</em> will also abort if there are any changes
884 registered in the index relative to the <tt>HEAD</tt> commit. (One
885 exception is when the changed index entries are in the state that
886 would result from the merge already.)</p></div>
887 <div class="paragraph"><p>If all named commits are already ancestors of <tt>HEAD</tt>, <em>git merge</em>
888 will exit early with the message "Already up-to-date."</p></div>
889 </div>
890 <h2 id="_fast_forward_merge">FAST-FORWARD MERGE</h2>
891 <div class="sectionbody">
892 <div class="paragraph"><p>Often the current branch head is an ancestor of the named commit.
893 This is the most common case especially when invoked from <em>git
894 pull</em>: you are tracking an upstream repository, you have committed
895 no local changes, and now you want to update to a newer upstream
896 revision. In this case, a new commit is not needed to store the
897 combined history; instead, the <tt>HEAD</tt> (along with the index) is
898 updated to point at the named commit, without creating an extra
899 merge commit.</p></div>
900 <div class="paragraph"><p>This behavior can be suppressed with the <tt>--no-ff</tt> option.</p></div>
901 </div>
902 <h2 id="_true_merge">TRUE MERGE</h2>
903 <div class="sectionbody">
904 <div class="paragraph"><p>Except in a fast-forward merge (see above), the branches to be
905 merged must be tied together by a merge commit that has both of them
906 as its parents.</p></div>
907 <div class="paragraph"><p>A merged version reconciling the changes from all branches to be
908 merged is committed, and your <tt>HEAD</tt>, index, and working tree are
909 updated to it. It is possible to have modifications in the working
910 tree as long as they do not overlap; the update will preserve them.</p></div>
911 <div class="paragraph"><p>When it is not obvious how to reconcile the changes, the following
912 happens:</p></div>
913 <div class="olist arabic"><ol class="arabic">
914 <li>
916 The <tt>HEAD</tt> pointer stays the same.
917 </p>
918 </li>
919 <li>
921 The <tt>MERGE_HEAD</tt> ref is set to point to the other branch head.
922 </p>
923 </li>
924 <li>
926 Paths that merged cleanly are updated both in the index file and
927 in your working tree.
928 </p>
929 </li>
930 <li>
932 For conflicting paths, the index file records up to three
933 versions: stage 1 stores the version from the common ancestor,
934 stage 2 from <tt>HEAD</tt>, and stage 3 from <tt>MERGE_HEAD</tt> (you
935 can inspect the stages with <tt>git ls-files -u</tt>). The working
936 tree files contain the result of the "merge" program; i.e. 3-way
937 merge results with familiar conflict markers <tt>&lt;&lt;&lt;</tt> <tt>===</tt> <tt>&gt;&gt;&gt;</tt>.
938 </p>
939 </li>
940 <li>
942 No other changes are made. In particular, the local
943 modifications you had before you started merge will stay the
944 same and the index entries for them stay as they were,
945 i.e. matching <tt>HEAD</tt>.
946 </p>
947 </li>
948 </ol></div>
949 <div class="paragraph"><p>If you tried a merge which resulted in complex conflicts and
950 want to start over, you can recover with <tt>git merge --abort</tt>.</p></div>
951 </div>
952 <h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
953 <div class="sectionbody">
954 <div class="paragraph"><p>During a merge, the working tree files are updated to reflect the result
955 of the merge. Among the changes made to the common ancestor&#8217;s version,
956 non-overlapping ones (that is, you changed an area of the file while the
957 other side left that area intact, or vice versa) are incorporated in the
958 final result verbatim. When both sides made changes to the same area,
959 however, git cannot randomly pick one side over the other, and asks you to
960 resolve it by leaving what both sides did to that area.</p></div>
961 <div class="paragraph"><p>By default, git uses the same style as that is used by "merge" program
962 from the RCS suite to present such a conflicted hunk, like this:</p></div>
963 <div class="listingblock">
964 <div class="content">
965 <pre><tt>Here are lines that are either unchanged from the common
966 ancestor, or cleanly resolved because only one side changed.
967 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
968 Conflict resolution is hard;
969 let's go shopping.
970 =======
971 Git makes conflict resolution easy.
972 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
973 And here is another line that is cleanly resolved or unmodified.</tt></pre>
974 </div></div>
975 <div class="paragraph"><p>The area where a pair of conflicting changes happened is marked with markers
976 <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>
977 is typically your side, and the part afterwards is typically their side.</p></div>
978 <div class="paragraph"><p>The default format does not show what the original said in the conflicting
979 area. You cannot tell how many lines are deleted and replaced with
980 Barbie&#8217;s remark on your side. The only thing you can tell is that your
981 side wants to say it is hard and you&#8217;d prefer to go shopping, while the
982 other side wants to claim it is easy.</p></div>
983 <div class="paragraph"><p>An alternative style can be used by setting the "merge.conflictstyle"
984 configuration variable to "diff3". In "diff3" style, the above conflict
985 may look like this:</p></div>
986 <div class="listingblock">
987 <div class="content">
988 <pre><tt>Here are lines that are either unchanged from the common
989 ancestor, or cleanly resolved because only one side changed.
990 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
991 Conflict resolution is hard;
992 let's go shopping.
993 |||||||
994 Conflict resolution is hard.
995 =======
996 Git makes conflict resolution easy.
997 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
998 And here is another line that is cleanly resolved or unmodified.</tt></pre>
999 </div></div>
1000 <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
1001 another <tt>|||||||</tt> marker that is followed by the original text. You can
1002 tell that the original just stated a fact, and your side simply gave in to
1003 that statement and gave up, while the other side tried to have a more
1004 positive attitude. You can sometimes come up with a better resolution by
1005 viewing the original.</p></div>
1006 </div>
1007 <h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
1008 <div class="sectionbody">
1009 <div class="paragraph"><p>After seeing a conflict, you can do two things:</p></div>
1010 <div class="ulist"><ul>
1011 <li>
1013 Decide not to merge. The only clean-ups you need are to reset
1014 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
1015 up working tree changes made by 2. and 3.; <tt>git merge --abort</tt>
1016 can be used for this.
1017 </p>
1018 </li>
1019 <li>
1021 Resolve the conflicts. Git will mark the conflicts in
1022 the working tree. Edit the files into shape and
1023 <em>git add</em> them to the index. Use <em>git commit</em> to seal the deal.
1024 </p>
1025 </li>
1026 </ul></div>
1027 <div class="paragraph"><p>You can work through the conflict with a number of tools:</p></div>
1028 <div class="ulist"><ul>
1029 <li>
1031 Use a mergetool. <tt>git mergetool</tt> to launch a graphical
1032 mergetool which will work you through the merge.
1033 </p>
1034 </li>
1035 <li>
1037 Look at the diffs. <tt>git diff</tt> will show a three-way diff,
1038 highlighting changes from both the <tt>HEAD</tt> and <tt>MERGE_HEAD</tt>
1039 versions.
1040 </p>
1041 </li>
1042 <li>
1044 Look at the diffs from each branch. <tt>git log --merge -p &lt;path&gt;</tt>
1045 will show diffs first for the <tt>HEAD</tt> version and then the
1046 <tt>MERGE_HEAD</tt> version.
1047 </p>
1048 </li>
1049 <li>
1051 Look at the originals. <tt>git show :1:filename</tt> shows the
1052 common ancestor, <tt>git show :2:filename</tt> shows the <tt>HEAD</tt>
1053 version, and <tt>git show :3:filename</tt> shows the <tt>MERGE_HEAD</tt>
1054 version.
1055 </p>
1056 </li>
1057 </ul></div>
1058 </div>
1059 <h2 id="_examples">EXAMPLES</h2>
1060 <div class="sectionbody">
1061 <div class="ulist"><ul>
1062 <li>
1064 Merge branches <tt>fixes</tt> and <tt>enhancements</tt> on top of
1065 the current branch, making an octopus merge:
1066 </p>
1067 <div class="listingblock">
1068 <div class="content">
1069 <pre><tt>$ git merge fixes enhancements</tt></pre>
1070 </div></div>
1071 </li>
1072 <li>
1074 Merge branch <tt>obsolete</tt> into the current branch, using <tt>ours</tt>
1075 merge strategy:
1076 </p>
1077 <div class="listingblock">
1078 <div class="content">
1079 <pre><tt>$ git merge -s ours obsolete</tt></pre>
1080 </div></div>
1081 </li>
1082 <li>
1084 Merge branch <tt>maint</tt> into the current branch, but do not make
1085 a new commit automatically:
1086 </p>
1087 <div class="listingblock">
1088 <div class="content">
1089 <pre><tt>$ git merge --no-commit maint</tt></pre>
1090 </div></div>
1091 <div class="paragraph"><p>This can be used when you want to include further changes to the
1092 merge, or want to write your own merge commit message.</p></div>
1093 <div class="paragraph"><p>You should refrain from abusing this option to sneak substantial
1094 changes into a merge commit. Small fixups like bumping
1095 release/version name would be acceptable.</p></div>
1096 </li>
1097 </ul></div>
1098 </div>
1099 <h2 id="_merge_strategies">MERGE STRATEGIES</h2>
1100 <div class="sectionbody">
1101 <div class="paragraph"><p>The merge mechanism (<em>git-merge</em> and <em>git-pull</em> commands) allows the
1102 backend <em>merge strategies</em> to be chosen with <tt>-s</tt> option. Some strategies
1103 can also take their own options, which can be passed by giving <tt>-X&lt;option&gt;</tt>
1104 arguments to <em>git-merge</em> and/or <em>git-pull</em>.</p></div>
1105 <div class="dlist"><dl>
1106 <dt class="hdlist1">
1107 resolve
1108 </dt>
1109 <dd>
1111 This can only resolve two heads (i.e. the current branch
1112 and another branch you pulled from) using a 3-way merge
1113 algorithm. It tries to carefully detect criss-cross
1114 merge ambiguities and is considered generally safe and
1115 fast.
1116 </p>
1117 </dd>
1118 <dt class="hdlist1">
1119 recursive
1120 </dt>
1121 <dd>
1123 This can only resolve two heads using a 3-way merge
1124 algorithm. When there is more than one common
1125 ancestor that can be used for 3-way merge, it creates a
1126 merged tree of the common ancestors and uses that as
1127 the reference tree for the 3-way merge. This has been
1128 reported to result in fewer merge conflicts without
1129 causing mis-merges by tests done on actual merge commits
1130 taken from Linux 2.6 kernel development history.
1131 Additionally this can detect and handle merges involving
1132 renames. This is the default merge strategy when
1133 pulling or merging one branch.
1134 </p>
1135 <div class="paragraph"><p>The <em>recursive</em> strategy can take the following options:</p></div>
1136 <div class="dlist"><dl>
1137 <dt class="hdlist1">
1138 ours
1139 </dt>
1140 <dd>
1142 This option forces conflicting hunks to be auto-resolved cleanly by
1143 favoring <em>our</em> version. Changes from the other tree that do not
1144 conflict with our side are reflected to the merge result.
1145 </p>
1146 <div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
1147 even look at what the other tree contains at all. It discards everything
1148 the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
1149 </dd>
1150 <dt class="hdlist1">
1151 theirs
1152 </dt>
1153 <dd>
1155 This is opposite of <em>ours</em>.
1156 </p>
1157 </dd>
1158 <dt class="hdlist1">
1159 patience
1160 </dt>
1161 <dd>
1163 With this option, <em>merge-recursive</em> spends a little extra time
1164 to avoid mismerges that sometimes occur due to unimportant
1165 matching lines (e.g., braces from distinct functions). Use
1166 this when the branches to be merged have diverged wildly.
1167 See also <a href="git-diff.html">git-diff(1)</a> <tt>--patience</tt>.
1168 </p>
1169 </dd>
1170 <dt class="hdlist1">
1171 ignore-space-change
1172 </dt>
1173 <dt class="hdlist1">
1174 ignore-all-space
1175 </dt>
1176 <dt class="hdlist1">
1177 ignore-space-at-eol
1178 </dt>
1179 <dd>
1181 Treats lines with the indicated type of whitespace change as
1182 unchanged for the sake of a three-way merge. Whitespace
1183 changes mixed with other changes to a line are not ignored.
1184 See also <a href="git-diff.html">git-diff(1)</a> <tt>-b</tt>, <tt>-w</tt>, and
1185 <tt>--ignore-space-at-eol</tt>.
1186 </p>
1187 <div class="ulist"><ul>
1188 <li>
1190 If <em>their</em> version only introduces whitespace changes to a line,
1191 <em>our</em> version is used;
1192 </p>
1193 </li>
1194 <li>
1196 If <em>our</em> version introduces whitespace changes but <em>their</em>
1197 version includes a substantial change, <em>their</em> version is used;
1198 </p>
1199 </li>
1200 <li>
1202 Otherwise, the merge proceeds in the usual way.
1203 </p>
1204 </li>
1205 </ul></div>
1206 </dd>
1207 <dt class="hdlist1">
1208 renormalize
1209 </dt>
1210 <dd>
1212 This runs a virtual check-out and check-in of all three stages
1213 of a file when resolving a three-way merge. This option is
1214 meant to be used when merging branches with different clean
1215 filters or end-of-line normalization rules. See "Merging
1216 branches with differing checkin/checkout attributes" in
1217 <a href="gitattributes.html">gitattributes(5)</a> for details.
1218 </p>
1219 </dd>
1220 <dt class="hdlist1">
1221 no-renormalize
1222 </dt>
1223 <dd>
1225 Disables the <tt>renormalize</tt> option. This overrides the
1226 <tt>merge.renormalize</tt> configuration variable.
1227 </p>
1228 </dd>
1229 <dt class="hdlist1">
1230 rename-threshold=&lt;n&gt;
1231 </dt>
1232 <dd>
1234 Controls the similarity threshold used for rename detection.
1235 See also <a href="git-diff.html">git-diff(1)</a> <tt>-M</tt>.
1236 </p>
1237 </dd>
1238 <dt class="hdlist1">
1239 subtree[=&lt;path&gt;]
1240 </dt>
1241 <dd>
1243 This option is a more advanced form of <em>subtree</em> strategy, where
1244 the strategy makes a guess on how two trees must be shifted to
1245 match with each other when merging. Instead, the specified path
1246 is prefixed (or stripped from the beginning) to make the shape of
1247 two trees to match.
1248 </p>
1249 </dd>
1250 </dl></div>
1251 </dd>
1252 <dt class="hdlist1">
1253 octopus
1254 </dt>
1255 <dd>
1257 This resolves cases with more than two heads, but refuses to do
1258 a complex merge that needs manual resolution. It is
1259 primarily meant to be used for bundling topic branch
1260 heads together. This is the default merge strategy when
1261 pulling or merging more than one branch.
1262 </p>
1263 </dd>
1264 <dt class="hdlist1">
1265 ours
1266 </dt>
1267 <dd>
1269 This resolves any number of heads, but the resulting tree of the
1270 merge is always that of the current branch head, effectively
1271 ignoring all changes from all other branches. It is meant to
1272 be used to supersede old development history of side
1273 branches. Note that this is different from the -Xours option to
1274 the <em>recursive</em> merge strategy.
1275 </p>
1276 </dd>
1277 <dt class="hdlist1">
1278 subtree
1279 </dt>
1280 <dd>
1282 This is a modified recursive strategy. When merging trees A and
1283 B, if B corresponds to a subtree of A, B is first adjusted to
1284 match the tree structure of A, instead of reading the trees at
1285 the same level. This adjustment is also done to the common
1286 ancestor tree.
1287 </p>
1288 </dd>
1289 </dl></div>
1290 </div>
1291 <h2 id="_configuration">CONFIGURATION</h2>
1292 <div class="sectionbody">
1293 <div class="dlist"><dl>
1294 <dt class="hdlist1">
1295 merge.conflictstyle
1296 </dt>
1297 <dd>
1299 Specify the style in which conflicted hunks are written out to
1300 working tree files upon merge. The default is "merge", which
1301 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
1302 a <tt>=======</tt> marker, changes made by the other side, and then
1303 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
1304 marker and the original text before the <tt>=======</tt> marker.
1305 </p>
1306 </dd>
1307 <dt class="hdlist1">
1308 merge.defaultToUpstream
1309 </dt>
1310 <dd>
1312 If merge is called without any commit argument, merge the upstream
1313 branches configured for the current branch by using their last
1314 observed values stored in their remote tracking branches.
1315 The values of the <tt>branch.&lt;current branch&gt;.merge</tt> that name the
1316 branches at the remote named by <tt>branch.&lt;current branch&gt;.remote</tt>
1317 are consulted, and then they are mapped via <tt>remote.&lt;remote&gt;.fetch</tt>
1318 to their corresponding remote tracking branches, and the tips of
1319 these tracking branches are merged.
1320 </p>
1321 </dd>
1322 <dt class="hdlist1">
1323 merge.ff
1324 </dt>
1325 <dd>
1327 By default, git does not create an extra merge commit when merging
1328 a commit that is a descendant of the current commit. Instead, the
1329 tip of the current branch is fast-forwarded. When set to <tt>false</tt>,
1330 this variable tells git to create an extra merge commit in such
1331 a case (equivalent to giving the <tt>--no-ff</tt> option from the command
1332 line). When set to <tt>only</tt>, only such fast-forward merges are
1333 allowed (equivalent to giving the <tt>--ff-only</tt> option from the
1334 command line).
1335 </p>
1336 </dd>
1337 <dt class="hdlist1">
1338 merge.log
1339 </dt>
1340 <dd>
1342 In addition to branch names, populate the log message with at
1343 most the specified number of one-line descriptions from the
1344 actual commits that are being merged. Defaults to false, and
1345 true is a synonym for 20.
1346 </p>
1347 </dd>
1348 <dt class="hdlist1">
1349 merge.renameLimit
1350 </dt>
1351 <dd>
1353 The number of files to consider when performing rename detection
1354 during a merge; if not specified, defaults to the value of
1355 diff.renameLimit.
1356 </p>
1357 </dd>
1358 <dt class="hdlist1">
1359 merge.renormalize
1360 </dt>
1361 <dd>
1363 Tell git that canonical representation of files in the
1364 repository has changed over time (e.g. earlier commits record
1365 text files with CRLF line endings, but recent ones use LF line
1366 endings). In such a repository, git can convert the data
1367 recorded in commits to a canonical form before performing a
1368 merge to reduce unnecessary conflicts. For more information,
1369 see section "Merging branches with differing checkin/checkout
1370 attributes" in <a href="gitattributes.html">gitattributes(5)</a>.
1371 </p>
1372 </dd>
1373 <dt class="hdlist1">
1374 merge.stat
1375 </dt>
1376 <dd>
1378 Whether to print the diffstat between ORIG_HEAD and the merge result
1379 at the end of the merge. True by default.
1380 </p>
1381 </dd>
1382 <dt class="hdlist1">
1383 merge.tool
1384 </dt>
1385 <dd>
1387 Controls which merge resolution program is used by
1388 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "araxis",
1389 "bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
1390 "opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
1391 and "xxdiff". Any other value is treated is custom merge tool
1392 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
1393 </p>
1394 </dd>
1395 <dt class="hdlist1">
1396 merge.verbosity
1397 </dt>
1398 <dd>
1400 Controls the amount of output shown by the recursive merge
1401 strategy. Level 0 outputs nothing except a final error
1402 message if conflicts were detected. Level 1 outputs only
1403 conflicts, 2 outputs conflicts and file changes. Level 5 and
1404 above outputs debugging information. The default is level 2.
1405 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
1406 </p>
1407 </dd>
1408 <dt class="hdlist1">
1409 merge.&lt;driver&gt;.name
1410 </dt>
1411 <dd>
1413 Defines a human-readable name for a custom low-level
1414 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1415 </p>
1416 </dd>
1417 <dt class="hdlist1">
1418 merge.&lt;driver&gt;.driver
1419 </dt>
1420 <dd>
1422 Defines the command that implements a custom low-level
1423 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1424 </p>
1425 </dd>
1426 <dt class="hdlist1">
1427 merge.&lt;driver&gt;.recursive
1428 </dt>
1429 <dd>
1431 Names a low-level merge driver to be used when
1432 performing an internal merge between common ancestors.
1433 See <a href="gitattributes.html">gitattributes(5)</a> for details.
1434 </p>
1435 </dd>
1436 <dt class="hdlist1">
1437 branch.&lt;name&gt;.mergeoptions
1438 </dt>
1439 <dd>
1441 Sets default options for merging into branch &lt;name&gt;. The syntax and
1442 supported options are the same as those of <em>git merge</em>, but option
1443 values containing whitespace characters are currently not supported.
1444 </p>
1445 </dd>
1446 </dl></div>
1447 </div>
1448 <h2 id="_see_also">SEE ALSO</h2>
1449 <div class="sectionbody">
1450 <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>,
1451 <a href="gitattributes.html">gitattributes(5)</a>,
1452 <a href="git-reset.html">git-reset(1)</a>,
1453 <a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1454 <a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
1455 <a href="git-mergetool.html">git-mergetool(1)</a></p></div>
1456 </div>
1457 <h2 id="_git">GIT</h2>
1458 <div class="sectionbody">
1459 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1460 </div>
1461 </div>
1462 <div id="footnotes"><hr /></div>
1463 <div id="footer">
1464 <div id="footer-text">
1465 Last updated 2011-09-21 23:01:14 PDT
1466 </div>
1467 </div>
1468 </body>
1469 </html>