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">
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">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.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
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
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
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
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
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
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
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 */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
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
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);
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");
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");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
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>";
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
;
550 noteholder
.parentNode
.removeChild(noteholder
);
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.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 git-merge(
1) Manual Page
576 <div class=
"sectionbody">
578 Join two or more development histories together
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
<strategy
>] [-X
<strategy-option
>]
588 [--[no-]rerere-autoupdate] [-m
<msg
>] [
<commit
>…]
589 <em>git merge
</em> <msg
> HEAD
<commit
>…
590 <em>git merge
</em> --abort
</div>
591 <div class=
"verseblock-attribution">
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>
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>
620 <div class=
"paragraph"><p>The second syntax (
<msg
> <tt>HEAD
</tt> <commit
>…) 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
<msg
> <commit
>…</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>
634 <h2 id=
"_options">OPTIONS
</h2>
635 <div class=
"sectionbody">
636 <div class=
"dlist"><dl>
645 Perform the merge and commit the result. This option can
646 be used to override --no-commit.
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>
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>
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.
677 <div class=
"paragraph"><p>With --no-ff Generate a merge commit even if the merge
678 resolved as a fast-forward.
</p></div>
688 In addition to branch names, populate the log message with
689 one-line descriptions from at most
<n
> actual commits that are being
690 merged. See also
<a href=
"git-fmt-merge-msg.html">git-fmt-merge-msg(
1)
</a>.
692 <div class=
"paragraph"><p>With --no-log do not list one-line descriptions from the
693 actual commits being merged.
</p></div>
706 Show a diffstat at the end of the merge. The diffstat is also
707 controlled by the configuration option merge.stat.
709 <div class=
"paragraph"><p>With -n or --no-stat do not show a diffstat at the end of the
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).
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>
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.
746 --strategy=
<strategy
>
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).
761 --strategy-option=
<option
>
765 Pass merge strategy specific option through to the merge
777 Synonyms to --stat and --no-stat; these are deprecated and will be
778 removed in the future.
789 Operate quietly. Implies --no-progress.
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
822 Set the commit message to be used for the merge commit (in
823 case one is created).
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>
835 --no-rerere-autoupdate
839 Allow the rerere mechanism to update the index with the
840 result of auto-conflict resolution if possible.
848 Abort the current conflict resolution process, and
849 try to reconstruct the pre-merge state.
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>
859 <commit
>…
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).
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>
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>
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>
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
913 <div class=
"olist arabic"><ol class=
"arabic">
916 The
<tt>HEAD
</tt> pointer stays the same.
921 The
<tt>MERGE_HEAD
</tt> ref is set to point to the other branch head.
926 Paths that merged cleanly are updated both in the index file and
927 in your working tree.
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><<<</tt> <tt>===
</tt> <tt>>>></tt>.
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>.
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>
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
’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 <<<<<<< yours:sample.txt
968 Conflict resolution is hard;
971 Git makes conflict resolution easy.
972 >>>>>>> theirs:sample.txt
973 And here is another line that is cleanly resolved or unmodified.
</tt></pre>
975 <div class=
"paragraph"><p>The area where a pair of conflicting changes happened is marked with markers
976 <tt><<<<<<<</tt>,
<tt>=======
</tt>, and
<tt>>>>>>>></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
’s remark on your side. The only thing you can tell is that your
981 side wants to say it is hard and you
’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 <<<<<<< yours:sample.txt
991 Conflict resolution is hard;
994 Conflict resolution is hard.
996 Git makes conflict resolution easy.
997 >>>>>>> theirs:sample.txt
998 And here is another line that is cleanly resolved or unmodified.
</tt></pre>
1000 <div class=
"paragraph"><p>In addition to the
<tt><<<<<<<</tt>,
<tt>=======
</tt>, and
<tt>>>>>>>></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>
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>
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.
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.
1027 <div class=
"paragraph"><p>You can work through the conflict with a number of tools:
</p></div>
1028 <div class=
"ulist"><ul>
1031 Use a mergetool.
<tt>git mergetool
</tt> to launch a graphical
1032 mergetool which will work you through the merge.
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>
1044 Look at the diffs from each branch.
<tt>git log --merge -p
<path
></tt>
1045 will show diffs first for the
<tt>HEAD
</tt> version and then the
1046 <tt>MERGE_HEAD
</tt> version.
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>
1059 <h2 id=
"_examples">EXAMPLES
</h2>
1060 <div class=
"sectionbody">
1061 <div class=
"ulist"><ul>
1064 Merge branches
<tt>fixes
</tt> and
<tt>enhancements
</tt> on top of
1065 the current branch, making an octopus merge:
1067 <div class=
"listingblock">
1068 <div class=
"content">
1069 <pre><tt>$ git merge fixes enhancements
</tt></pre>
1074 Merge branch
<tt>obsolete
</tt> into the current branch, using
<tt>ours
</tt>
1077 <div class=
"listingblock">
1078 <div class=
"content">
1079 <pre><tt>$ git merge -s ours obsolete
</tt></pre>
1084 Merge branch
<tt>maint
</tt> into the current branch, but do not make
1085 a new commit automatically:
1087 <div class=
"listingblock">
1088 <div class=
"content">
1089 <pre><tt>$ git merge --no-commit maint
</tt></pre>
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>
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
<option
></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">
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
1118 <dt class=
"hdlist1">
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.
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">
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.
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>
1150 <dt class=
"hdlist1">
1155 This is opposite of
<em>ours
</em>.
1158 <dt class=
"hdlist1">
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>.
1170 <dt class=
"hdlist1">
1173 <dt class=
"hdlist1">
1176 <dt class=
"hdlist1">
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>.
1187 <div class=
"ulist"><ul>
1190 If
<em>their
</em> version only introduces whitespace changes to a line,
1191 <em>our
</em> version is used;
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;
1202 Otherwise, the merge proceeds in the usual way.
1207 <dt class=
"hdlist1">
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.
1220 <dt class=
"hdlist1">
1225 Disables the
<tt>renormalize
</tt> option. This overrides the
1226 <tt>merge.renormalize
</tt> configuration variable.
1229 <dt class=
"hdlist1">
1230 rename-threshold=
<n
>
1234 Controls the similarity threshold used for rename detection.
1235 See also
<a href=
"git-diff.html">git-diff(
1)
</a> <tt>-M
</tt>.
1238 <dt class=
"hdlist1">
1239 subtree[=
<path
>]
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
1252 <dt class=
"hdlist1">
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.
1264 <dt class=
"hdlist1">
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.
1277 <dt class=
"hdlist1">
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
1291 <h2 id=
"_configuration">CONFIGURATION
</h2>
1292 <div class=
"sectionbody">
1293 <div class=
"dlist"><dl>
1294 <dt class=
"hdlist1">
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><<<<<<<</tt> conflict marker, changes made by one side,
1302 a
<tt>=======
</tt> marker, changes made by the other side, and then
1303 a
<tt>>>>>>>></tt> marker. An alternate style,
"diff3", adds a
<tt>|||||||
</tt>
1304 marker and the original text before the
<tt>=======
</tt> marker.
1307 <dt class=
"hdlist1">
1308 merge.defaultToUpstream
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.
<current branch
>.merge
</tt> that name the
1316 branches at the remote named by
<tt>branch.
<current branch
>.remote
</tt>
1317 are consulted, and then they are mapped via
<tt>remote.
<remote
>.fetch
</tt>
1318 to their corresponding remote tracking branches, and the tips of
1319 these tracking branches are merged.
1322 <dt class=
"hdlist1">
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
1337 <dt class=
"hdlist1">
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.
1348 <dt class=
"hdlist1">
1353 The number of files to consider when performing rename detection
1354 during a merge; if not specified, defaults to the value of
1358 <dt class=
"hdlist1">
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>.
1373 <dt class=
"hdlist1">
1378 Whether to print the diffstat between ORIG_HEAD and the merge result
1379 at the end of the merge. True by default.
1382 <dt class=
"hdlist1">
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.
<tool
>.cmd option.
1395 <dt class=
"hdlist1">
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.
1408 <dt class=
"hdlist1">
1409 merge.
<driver
>.name
1413 Defines a human-readable name for a custom low-level
1414 merge driver. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
1417 <dt class=
"hdlist1">
1418 merge.
<driver
>.driver
1422 Defines the command that implements a custom low-level
1423 merge driver. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
1426 <dt class=
"hdlist1">
1427 merge.
<driver
>.recursive
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.
1436 <dt class=
"hdlist1">
1437 branch.
<name
>.mergeoptions
1441 Sets default options for merging into branch
<name
>. 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.
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>
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>
1462 <div id=
"footnotes"><hr /></div>
1464 <div id=
"footer-text">
1465 Last updated
2011-
09-
21 23:
01:
14 PDT