Autogenerated HTML docs for v1.7.7-290-gc9e7aa
[git/jnareb-git.git] / git-merge.html
blob426cf144a313b1879e5403f334ec5824bf7f2a48
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 --ff
654 </dt>
655 <dt class="hdlist1">
656 --no-ff
657 </dt>
658 <dd>
660 Do not generate a merge commit if the merge resolved as
661 a fast-forward, only update the branch pointer. This is
662 the default behavior of git-merge.
663 </p>
664 <div class="paragraph"><p>With --no-ff Generate a merge commit even if the merge
665 resolved as a fast-forward.</p></div>
666 </dd>
667 <dt class="hdlist1">
668 --log[=&lt;n&gt;]
669 </dt>
670 <dt class="hdlist1">
671 --no-log
672 </dt>
673 <dd>
675 In addition to branch names, populate the log message with
676 one-line descriptions from at most &lt;n&gt; actual commits that are being
677 merged. See also <a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>.
678 </p>
679 <div class="paragraph"><p>With --no-log do not list one-line descriptions from the
680 actual commits being merged.</p></div>
681 </dd>
682 <dt class="hdlist1">
683 --stat
684 </dt>
685 <dt class="hdlist1">
687 </dt>
688 <dt class="hdlist1">
689 --no-stat
690 </dt>
691 <dd>
693 Show a diffstat at the end of the merge. The diffstat is also
694 controlled by the configuration option merge.stat.
695 </p>
696 <div class="paragraph"><p>With -n or --no-stat do not show a diffstat at the end of the
697 merge.</p></div>
698 </dd>
699 <dt class="hdlist1">
700 --squash
701 </dt>
702 <dt class="hdlist1">
703 --no-squash
704 </dt>
705 <dd>
707 Produce the working tree and index state as if a real
708 merge happened (except for the merge information),
709 but do not actually make a commit or
710 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
711 cause the next <tt>git commit</tt> command to create a merge
712 commit. This allows you to create a single commit on
713 top of the current branch whose effect is the same as
714 merging another branch (or more in case of an octopus).
715 </p>
716 <div class="paragraph"><p>With --no-squash perform the merge and commit the result. This
717 option can be used to override --squash.</p></div>
718 </dd>
719 <dt class="hdlist1">
720 --ff-only
721 </dt>
722 <dd>
724 Refuse to merge and exit with a non-zero status unless the
725 current <tt>HEAD</tt> is already up-to-date or the merge can be
726 resolved as a fast-forward.
727 </p>
728 </dd>
729 <dt class="hdlist1">
730 -s &lt;strategy&gt;
731 </dt>
732 <dt class="hdlist1">
733 --strategy=&lt;strategy&gt;
734 </dt>
735 <dd>
737 Use the given merge strategy; can be supplied more than
738 once to specify them in the order they should be tried.
739 If there is no <tt>-s</tt> option, a built-in list of strategies
740 is used instead (<em>git merge-recursive</em> when merging a single
741 head, <em>git merge-octopus</em> otherwise).
742 </p>
743 </dd>
744 <dt class="hdlist1">
745 -X &lt;option&gt;
746 </dt>
747 <dt class="hdlist1">
748 --strategy-option=&lt;option&gt;
749 </dt>
750 <dd>
752 Pass merge strategy specific option through to the merge
753 strategy.
754 </p>
755 </dd>
756 <dt class="hdlist1">
757 --summary
758 </dt>
759 <dt class="hdlist1">
760 --no-summary
761 </dt>
762 <dd>
764 Synonyms to --stat and --no-stat; these are deprecated and will be
765 removed in the future.
766 </p>
767 </dd>
768 <dt class="hdlist1">
770 </dt>
771 <dt class="hdlist1">
772 --quiet
773 </dt>
774 <dd>
776 Operate quietly. Implies --no-progress.
777 </p>
778 </dd>
779 <dt class="hdlist1">
781 </dt>
782 <dt class="hdlist1">
783 --verbose
784 </dt>
785 <dd>
787 Be verbose.
788 </p>
789 </dd>
790 <dt class="hdlist1">
791 --progress
792 </dt>
793 <dt class="hdlist1">
794 --no-progress
795 </dt>
796 <dd>
798 Turn progress on/off explicitly. If neither is specified,
799 progress is shown if standard error is connected to a terminal.
800 Note that not all merge strategies may support progress
801 reporting.
802 </p>
803 </dd>
804 <dt class="hdlist1">
805 -m &lt;msg&gt;
806 </dt>
807 <dd>
809 Set the commit message to be used for the merge commit (in
810 case one is created).
811 </p>
812 <div class="paragraph"><p>If <tt>--log</tt> is specified, a shortlog of the commits being merged
813 will be appended to the specified message.</p></div>
814 <div class="paragraph"><p>The <em>git fmt-merge-msg</em> command can be
815 used to give a good default for automated <em>git merge</em>
816 invocations.</p></div>
817 </dd>
818 <dt class="hdlist1">
819 --rerere-autoupdate
820 </dt>
821 <dt class="hdlist1">
822 --no-rerere-autoupdate
823 </dt>
824 <dd>
826 Allow the rerere mechanism to update the index with the
827 result of auto-conflict resolution if possible.
828 </p>
829 </dd>
830 <dt class="hdlist1">
831 --abort
832 </dt>
833 <dd>
835 Abort the current conflict resolution process, and
836 try to reconstruct the pre-merge state.
837 </p>
838 <div class="paragraph"><p>If there were uncommitted worktree changes present when the merge
839 started, <em>git merge --abort</em> will in some cases be unable to
840 reconstruct these changes. It is therefore recommended to always
841 commit or stash your changes before running <em>git merge</em>.</p></div>
842 <div class="paragraph"><p><em>git merge --abort</em> is equivalent to <em>git reset --merge</em> when
843 <tt>MERGE_HEAD</tt> is present.</p></div>
844 </dd>
845 <dt class="hdlist1">
846 &lt;commit&gt;&#8230;
847 </dt>
848 <dd>
850 Commits, usually other branch heads, to merge into our branch.
851 Specifying more than one commit will create a merge with
852 more than two parents (affectionately called an Octopus merge).
853 </p>
854 <div class="paragraph"><p>If no commit is given from the command line, and if <tt>merge.defaultToUpstream</tt>
855 configuration variable is set, merge the remote tracking branches
856 that the current branch is configured to use as its upstream.
857 See also the configuration section of this manual page.</p></div>
858 </dd>
859 </dl></div>
860 </div>
861 <h2 id="_pre_merge_checks">PRE-MERGE CHECKS</h2>
862 <div class="sectionbody">
863 <div class="paragraph"><p>Before applying outside changes, you should get your own work in
864 good shape and committed locally, so it will not be clobbered if
865 there are conflicts. See also <a href="git-stash.html">git-stash(1)</a>.
866 <em>git pull</em> and <em>git merge</em> will stop without doing anything when
867 local uncommitted changes overlap with files that <em>git pull</em>/<em>git
868 merge</em> may need to update.</p></div>
869 <div class="paragraph"><p>To avoid recording unrelated changes in the merge commit,
870 <em>git pull</em> and <em>git merge</em> will also abort if there are any changes
871 registered in the index relative to the <tt>HEAD</tt> commit. (One
872 exception is when the changed index entries are in the state that
873 would result from the merge already.)</p></div>
874 <div class="paragraph"><p>If all named commits are already ancestors of <tt>HEAD</tt>, <em>git merge</em>
875 will exit early with the message "Already up-to-date."</p></div>
876 </div>
877 <h2 id="_fast_forward_merge">FAST-FORWARD MERGE</h2>
878 <div class="sectionbody">
879 <div class="paragraph"><p>Often the current branch head is an ancestor of the named commit.
880 This is the most common case especially when invoked from <em>git
881 pull</em>: you are tracking an upstream repository, you have committed
882 no local changes, and now you want to update to a newer upstream
883 revision. In this case, a new commit is not needed to store the
884 combined history; instead, the <tt>HEAD</tt> (along with the index) is
885 updated to point at the named commit, without creating an extra
886 merge commit.</p></div>
887 <div class="paragraph"><p>This behavior can be suppressed with the <tt>--no-ff</tt> option.</p></div>
888 </div>
889 <h2 id="_true_merge">TRUE MERGE</h2>
890 <div class="sectionbody">
891 <div class="paragraph"><p>Except in a fast-forward merge (see above), the branches to be
892 merged must be tied together by a merge commit that has both of them
893 as its parents.</p></div>
894 <div class="paragraph"><p>A merged version reconciling the changes from all branches to be
895 merged is committed, and your <tt>HEAD</tt>, index, and working tree are
896 updated to it. It is possible to have modifications in the working
897 tree as long as they do not overlap; the update will preserve them.</p></div>
898 <div class="paragraph"><p>When it is not obvious how to reconcile the changes, the following
899 happens:</p></div>
900 <div class="olist arabic"><ol class="arabic">
901 <li>
903 The <tt>HEAD</tt> pointer stays the same.
904 </p>
905 </li>
906 <li>
908 The <tt>MERGE_HEAD</tt> ref is set to point to the other branch head.
909 </p>
910 </li>
911 <li>
913 Paths that merged cleanly are updated both in the index file and
914 in your working tree.
915 </p>
916 </li>
917 <li>
919 For conflicting paths, the index file records up to three
920 versions: stage 1 stores the version from the common ancestor,
921 stage 2 from <tt>HEAD</tt>, and stage 3 from <tt>MERGE_HEAD</tt> (you
922 can inspect the stages with <tt>git ls-files -u</tt>). The working
923 tree files contain the result of the "merge" program; i.e. 3-way
924 merge results with familiar conflict markers <tt>&lt;&lt;&lt;</tt> <tt>===</tt> <tt>&gt;&gt;&gt;</tt>.
925 </p>
926 </li>
927 <li>
929 No other changes are made. In particular, the local
930 modifications you had before you started merge will stay the
931 same and the index entries for them stay as they were,
932 i.e. matching <tt>HEAD</tt>.
933 </p>
934 </li>
935 </ol></div>
936 <div class="paragraph"><p>If you tried a merge which resulted in complex conflicts and
937 want to start over, you can recover with <tt>git merge --abort</tt>.</p></div>
938 </div>
939 <h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
940 <div class="sectionbody">
941 <div class="paragraph"><p>During a merge, the working tree files are updated to reflect the result
942 of the merge. Among the changes made to the common ancestor&#8217;s version,
943 non-overlapping ones (that is, you changed an area of the file while the
944 other side left that area intact, or vice versa) are incorporated in the
945 final result verbatim. When both sides made changes to the same area,
946 however, git cannot randomly pick one side over the other, and asks you to
947 resolve it by leaving what both sides did to that area.</p></div>
948 <div class="paragraph"><p>By default, git uses the same style as that is used by "merge" program
949 from the RCS suite to present such a conflicted hunk, like this:</p></div>
950 <div class="listingblock">
951 <div class="content">
952 <pre><tt>Here are lines that are either unchanged from the common
953 ancestor, or cleanly resolved because only one side changed.
954 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
955 Conflict resolution is hard;
956 let's go shopping.
957 =======
958 Git makes conflict resolution easy.
959 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
960 And here is another line that is cleanly resolved or unmodified.</tt></pre>
961 </div></div>
962 <div class="paragraph"><p>The area where a pair of conflicting changes happened is marked with markers
963 <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>
964 is typically your side, and the part afterwards is typically their side.</p></div>
965 <div class="paragraph"><p>The default format does not show what the original said in the conflicting
966 area. You cannot tell how many lines are deleted and replaced with
967 Barbie&#8217;s remark on your side. The only thing you can tell is that your
968 side wants to say it is hard and you&#8217;d prefer to go shopping, while the
969 other side wants to claim it is easy.</p></div>
970 <div class="paragraph"><p>An alternative style can be used by setting the "merge.conflictstyle"
971 configuration variable to "diff3". In "diff3" style, the above conflict
972 may look like this:</p></div>
973 <div class="listingblock">
974 <div class="content">
975 <pre><tt>Here are lines that are either unchanged from the common
976 ancestor, or cleanly resolved because only one side changed.
977 &lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
978 Conflict resolution is hard;
979 let's go shopping.
980 |||||||
981 Conflict resolution is hard.
982 =======
983 Git makes conflict resolution easy.
984 &gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
985 And here is another line that is cleanly resolved or unmodified.</tt></pre>
986 </div></div>
987 <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
988 another <tt>|||||||</tt> marker that is followed by the original text. You can
989 tell that the original just stated a fact, and your side simply gave in to
990 that statement and gave up, while the other side tried to have a more
991 positive attitude. You can sometimes come up with a better resolution by
992 viewing the original.</p></div>
993 </div>
994 <h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
995 <div class="sectionbody">
996 <div class="paragraph"><p>After seeing a conflict, you can do two things:</p></div>
997 <div class="ulist"><ul>
998 <li>
1000 Decide not to merge. The only clean-ups you need are to reset
1001 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
1002 up working tree changes made by 2. and 3.; <tt>git merge --abort</tt>
1003 can be used for this.
1004 </p>
1005 </li>
1006 <li>
1008 Resolve the conflicts. Git will mark the conflicts in
1009 the working tree. Edit the files into shape and
1010 <em>git add</em> them to the index. Use <em>git commit</em> to seal the deal.
1011 </p>
1012 </li>
1013 </ul></div>
1014 <div class="paragraph"><p>You can work through the conflict with a number of tools:</p></div>
1015 <div class="ulist"><ul>
1016 <li>
1018 Use a mergetool. <tt>git mergetool</tt> to launch a graphical
1019 mergetool which will work you through the merge.
1020 </p>
1021 </li>
1022 <li>
1024 Look at the diffs. <tt>git diff</tt> will show a three-way diff,
1025 highlighting changes from both the <tt>HEAD</tt> and <tt>MERGE_HEAD</tt>
1026 versions.
1027 </p>
1028 </li>
1029 <li>
1031 Look at the diffs from each branch. <tt>git log --merge -p &lt;path&gt;</tt>
1032 will show diffs first for the <tt>HEAD</tt> version and then the
1033 <tt>MERGE_HEAD</tt> version.
1034 </p>
1035 </li>
1036 <li>
1038 Look at the originals. <tt>git show :1:filename</tt> shows the
1039 common ancestor, <tt>git show :2:filename</tt> shows the <tt>HEAD</tt>
1040 version, and <tt>git show :3:filename</tt> shows the <tt>MERGE_HEAD</tt>
1041 version.
1042 </p>
1043 </li>
1044 </ul></div>
1045 </div>
1046 <h2 id="_examples">EXAMPLES</h2>
1047 <div class="sectionbody">
1048 <div class="ulist"><ul>
1049 <li>
1051 Merge branches <tt>fixes</tt> and <tt>enhancements</tt> on top of
1052 the current branch, making an octopus merge:
1053 </p>
1054 <div class="listingblock">
1055 <div class="content">
1056 <pre><tt>$ git merge fixes enhancements</tt></pre>
1057 </div></div>
1058 </li>
1059 <li>
1061 Merge branch <tt>obsolete</tt> into the current branch, using <tt>ours</tt>
1062 merge strategy:
1063 </p>
1064 <div class="listingblock">
1065 <div class="content">
1066 <pre><tt>$ git merge -s ours obsolete</tt></pre>
1067 </div></div>
1068 </li>
1069 <li>
1071 Merge branch <tt>maint</tt> into the current branch, but do not make
1072 a new commit automatically:
1073 </p>
1074 <div class="listingblock">
1075 <div class="content">
1076 <pre><tt>$ git merge --no-commit maint</tt></pre>
1077 </div></div>
1078 <div class="paragraph"><p>This can be used when you want to include further changes to the
1079 merge, or want to write your own merge commit message.</p></div>
1080 <div class="paragraph"><p>You should refrain from abusing this option to sneak substantial
1081 changes into a merge commit. Small fixups like bumping
1082 release/version name would be acceptable.</p></div>
1083 </li>
1084 </ul></div>
1085 </div>
1086 <h2 id="_merge_strategies">MERGE STRATEGIES</h2>
1087 <div class="sectionbody">
1088 <div class="paragraph"><p>The merge mechanism (<em>git-merge</em> and <em>git-pull</em> commands) allows the
1089 backend <em>merge strategies</em> to be chosen with <tt>-s</tt> option. Some strategies
1090 can also take their own options, which can be passed by giving <tt>-X&lt;option&gt;</tt>
1091 arguments to <em>git-merge</em> and/or <em>git-pull</em>.</p></div>
1092 <div class="dlist"><dl>
1093 <dt class="hdlist1">
1094 resolve
1095 </dt>
1096 <dd>
1098 This can only resolve two heads (i.e. the current branch
1099 and another branch you pulled from) using a 3-way merge
1100 algorithm. It tries to carefully detect criss-cross
1101 merge ambiguities and is considered generally safe and
1102 fast.
1103 </p>
1104 </dd>
1105 <dt class="hdlist1">
1106 recursive
1107 </dt>
1108 <dd>
1110 This can only resolve two heads using a 3-way merge
1111 algorithm. When there is more than one common
1112 ancestor that can be used for 3-way merge, it creates a
1113 merged tree of the common ancestors and uses that as
1114 the reference tree for the 3-way merge. This has been
1115 reported to result in fewer merge conflicts without
1116 causing mis-merges by tests done on actual merge commits
1117 taken from Linux 2.6 kernel development history.
1118 Additionally this can detect and handle merges involving
1119 renames. This is the default merge strategy when
1120 pulling or merging one branch.
1121 </p>
1122 <div class="paragraph"><p>The <em>recursive</em> strategy can take the following options:</p></div>
1123 <div class="dlist"><dl>
1124 <dt class="hdlist1">
1125 ours
1126 </dt>
1127 <dd>
1129 This option forces conflicting hunks to be auto-resolved cleanly by
1130 favoring <em>our</em> version. Changes from the other tree that do not
1131 conflict with our side are reflected to the merge result.
1132 </p>
1133 <div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
1134 even look at what the other tree contains at all. It discards everything
1135 the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
1136 </dd>
1137 <dt class="hdlist1">
1138 theirs
1139 </dt>
1140 <dd>
1142 This is opposite of <em>ours</em>.
1143 </p>
1144 </dd>
1145 <dt class="hdlist1">
1146 patience
1147 </dt>
1148 <dd>
1150 With this option, <em>merge-recursive</em> spends a little extra time
1151 to avoid mismerges that sometimes occur due to unimportant
1152 matching lines (e.g., braces from distinct functions). Use
1153 this when the branches to be merged have diverged wildly.
1154 See also <a href="git-diff.html">git-diff(1)</a> <tt>--patience</tt>.
1155 </p>
1156 </dd>
1157 <dt class="hdlist1">
1158 ignore-space-change
1159 </dt>
1160 <dt class="hdlist1">
1161 ignore-all-space
1162 </dt>
1163 <dt class="hdlist1">
1164 ignore-space-at-eol
1165 </dt>
1166 <dd>
1168 Treats lines with the indicated type of whitespace change as
1169 unchanged for the sake of a three-way merge. Whitespace
1170 changes mixed with other changes to a line are not ignored.
1171 See also <a href="git-diff.html">git-diff(1)</a> <tt>-b</tt>, <tt>-w</tt>, and
1172 <tt>--ignore-space-at-eol</tt>.
1173 </p>
1174 <div class="ulist"><ul>
1175 <li>
1177 If <em>their</em> version only introduces whitespace changes to a line,
1178 <em>our</em> version is used;
1179 </p>
1180 </li>
1181 <li>
1183 If <em>our</em> version introduces whitespace changes but <em>their</em>
1184 version includes a substantial change, <em>their</em> version is used;
1185 </p>
1186 </li>
1187 <li>
1189 Otherwise, the merge proceeds in the usual way.
1190 </p>
1191 </li>
1192 </ul></div>
1193 </dd>
1194 <dt class="hdlist1">
1195 renormalize
1196 </dt>
1197 <dd>
1199 This runs a virtual check-out and check-in of all three stages
1200 of a file when resolving a three-way merge. This option is
1201 meant to be used when merging branches with different clean
1202 filters or end-of-line normalization rules. See "Merging
1203 branches with differing checkin/checkout attributes" in
1204 <a href="gitattributes.html">gitattributes(5)</a> for details.
1205 </p>
1206 </dd>
1207 <dt class="hdlist1">
1208 no-renormalize
1209 </dt>
1210 <dd>
1212 Disables the <tt>renormalize</tt> option. This overrides the
1213 <tt>merge.renormalize</tt> configuration variable.
1214 </p>
1215 </dd>
1216 <dt class="hdlist1">
1217 rename-threshold=&lt;n&gt;
1218 </dt>
1219 <dd>
1221 Controls the similarity threshold used for rename detection.
1222 See also <a href="git-diff.html">git-diff(1)</a> <tt>-M</tt>.
1223 </p>
1224 </dd>
1225 <dt class="hdlist1">
1226 subtree[=&lt;path&gt;]
1227 </dt>
1228 <dd>
1230 This option is a more advanced form of <em>subtree</em> strategy, where
1231 the strategy makes a guess on how two trees must be shifted to
1232 match with each other when merging. Instead, the specified path
1233 is prefixed (or stripped from the beginning) to make the shape of
1234 two trees to match.
1235 </p>
1236 </dd>
1237 </dl></div>
1238 </dd>
1239 <dt class="hdlist1">
1240 octopus
1241 </dt>
1242 <dd>
1244 This resolves cases with more than two heads, but refuses to do
1245 a complex merge that needs manual resolution. It is
1246 primarily meant to be used for bundling topic branch
1247 heads together. This is the default merge strategy when
1248 pulling or merging more than one branch.
1249 </p>
1250 </dd>
1251 <dt class="hdlist1">
1252 ours
1253 </dt>
1254 <dd>
1256 This resolves any number of heads, but the resulting tree of the
1257 merge is always that of the current branch head, effectively
1258 ignoring all changes from all other branches. It is meant to
1259 be used to supersede old development history of side
1260 branches. Note that this is different from the -Xours option to
1261 the <em>recursive</em> merge strategy.
1262 </p>
1263 </dd>
1264 <dt class="hdlist1">
1265 subtree
1266 </dt>
1267 <dd>
1269 This is a modified recursive strategy. When merging trees A and
1270 B, if B corresponds to a subtree of A, B is first adjusted to
1271 match the tree structure of A, instead of reading the trees at
1272 the same level. This adjustment is also done to the common
1273 ancestor tree.
1274 </p>
1275 </dd>
1276 </dl></div>
1277 </div>
1278 <h2 id="_configuration">CONFIGURATION</h2>
1279 <div class="sectionbody">
1280 <div class="dlist"><dl>
1281 <dt class="hdlist1">
1282 merge.conflictstyle
1283 </dt>
1284 <dd>
1286 Specify the style in which conflicted hunks are written out to
1287 working tree files upon merge. The default is "merge", which
1288 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
1289 a <tt>=======</tt> marker, changes made by the other side, and then
1290 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
1291 marker and the original text before the <tt>=======</tt> marker.
1292 </p>
1293 </dd>
1294 <dt class="hdlist1">
1295 merge.defaultToUpstream
1296 </dt>
1297 <dd>
1299 If merge is called without any commit argument, merge the upstream
1300 branches configured for the current branch by using their last
1301 observed values stored in their remote tracking branches.
1302 The values of the <tt>branch.&lt;current branch&gt;.merge</tt> that name the
1303 branches at the remote named by <tt>branch.&lt;current branch&gt;.remote</tt>
1304 are consulted, and then they are mapped via <tt>remote.&lt;remote&gt;.fetch</tt>
1305 to their corresponding remote tracking branches, and the tips of
1306 these tracking branches are merged.
1307 </p>
1308 </dd>
1309 <dt class="hdlist1">
1310 merge.ff
1311 </dt>
1312 <dd>
1314 By default, git does not create an extra merge commit when merging
1315 a commit that is a descendant of the current commit. Instead, the
1316 tip of the current branch is fast-forwarded. When set to <tt>false</tt>,
1317 this variable tells git to create an extra merge commit in such
1318 a case (equivalent to giving the <tt>--no-ff</tt> option from the command
1319 line). When set to <tt>only</tt>, only such fast-forward merges are
1320 allowed (equivalent to giving the <tt>--ff-only</tt> option from the
1321 command line).
1322 </p>
1323 </dd>
1324 <dt class="hdlist1">
1325 merge.log
1326 </dt>
1327 <dd>
1329 In addition to branch names, populate the log message with at
1330 most the specified number of one-line descriptions from the
1331 actual commits that are being merged. Defaults to false, and
1332 true is a synonym for 20.
1333 </p>
1334 </dd>
1335 <dt class="hdlist1">
1336 merge.renameLimit
1337 </dt>
1338 <dd>
1340 The number of files to consider when performing rename detection
1341 during a merge; if not specified, defaults to the value of
1342 diff.renameLimit.
1343 </p>
1344 </dd>
1345 <dt class="hdlist1">
1346 merge.renormalize
1347 </dt>
1348 <dd>
1350 Tell git that canonical representation of files in the
1351 repository has changed over time (e.g. earlier commits record
1352 text files with CRLF line endings, but recent ones use LF line
1353 endings). In such a repository, git can convert the data
1354 recorded in commits to a canonical form before performing a
1355 merge to reduce unnecessary conflicts. For more information,
1356 see section "Merging branches with differing checkin/checkout
1357 attributes" in <a href="gitattributes.html">gitattributes(5)</a>.
1358 </p>
1359 </dd>
1360 <dt class="hdlist1">
1361 merge.stat
1362 </dt>
1363 <dd>
1365 Whether to print the diffstat between ORIG_HEAD and the merge result
1366 at the end of the merge. True by default.
1367 </p>
1368 </dd>
1369 <dt class="hdlist1">
1370 merge.tool
1371 </dt>
1372 <dd>
1374 Controls which merge resolution program is used by
1375 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "araxis",
1376 "bc3", "diffuse", "ecmerge", "emerge", "gvimdiff", "kdiff3", "meld",
1377 "opendiff", "p4merge", "tkdiff", "tortoisemerge", "vimdiff"
1378 and "xxdiff". Any other value is treated is custom merge tool
1379 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
1380 </p>
1381 </dd>
1382 <dt class="hdlist1">
1383 merge.verbosity
1384 </dt>
1385 <dd>
1387 Controls the amount of output shown by the recursive merge
1388 strategy. Level 0 outputs nothing except a final error
1389 message if conflicts were detected. Level 1 outputs only
1390 conflicts, 2 outputs conflicts and file changes. Level 5 and
1391 above outputs debugging information. The default is level 2.
1392 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
1393 </p>
1394 </dd>
1395 <dt class="hdlist1">
1396 merge.&lt;driver&gt;.name
1397 </dt>
1398 <dd>
1400 Defines a human-readable name for a custom low-level
1401 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1402 </p>
1403 </dd>
1404 <dt class="hdlist1">
1405 merge.&lt;driver&gt;.driver
1406 </dt>
1407 <dd>
1409 Defines the command that implements a custom low-level
1410 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
1411 </p>
1412 </dd>
1413 <dt class="hdlist1">
1414 merge.&lt;driver&gt;.recursive
1415 </dt>
1416 <dd>
1418 Names a low-level merge driver to be used when
1419 performing an internal merge between common ancestors.
1420 See <a href="gitattributes.html">gitattributes(5)</a> for details.
1421 </p>
1422 </dd>
1423 <dt class="hdlist1">
1424 branch.&lt;name&gt;.mergeoptions
1425 </dt>
1426 <dd>
1428 Sets default options for merging into branch &lt;name&gt;. The syntax and
1429 supported options are the same as those of <em>git merge</em>, but option
1430 values containing whitespace characters are currently not supported.
1431 </p>
1432 </dd>
1433 </dl></div>
1434 </div>
1435 <h2 id="_see_also">SEE ALSO</h2>
1436 <div class="sectionbody">
1437 <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>,
1438 <a href="gitattributes.html">gitattributes(5)</a>,
1439 <a href="git-reset.html">git-reset(1)</a>,
1440 <a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1441 <a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
1442 <a href="git-mergetool.html">git-mergetool(1)</a></p></div>
1443 </div>
1444 <h2 id="_git">GIT</h2>
1445 <div class="sectionbody">
1446 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1447 </div>
1448 </div>
1449 <div id="footnotes"><hr /></div>
1450 <div id="footer">
1451 <div id="footer-text">
1452 Last updated 2011-09-21 23:01:14 PDT
1453 </div>
1454 </div>
1455 </body>
1456 </html>