blob: 85d772bcf34feee1f6aa0d1b8f9cb581a66793ac [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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" />
Junio C Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1a4e8412005-12-27 08:17:2326
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2384}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1a4e8412005-12-27 08:17:23155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1a4e8412005-12-27 08:17:23236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1a4e8412005-12-27 08:17:23275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-merge(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-merge(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-merge -
Junio C Hamano7c73c662007-01-19 00:37:50317 Join two or more development histories together
Junio C Hamano1a4e8412005-12-27 08:17:23318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoee6d9612006-11-27 20:03:22323<div class="verseblock">
Junio C Hamanofce7c7e2008-07-02 03:06:38324<div class="content"><em>git merge</em> [-n] [--stat] [--no-commit] [--squash] [-s &lt;strategy&gt;]&#8230;
Junio C Hamano1974bf22007-10-31 05:57:20325 [-m &lt;msg&gt;] &lt;remote&gt; &lt;remote&gt;&#8230;
Junio C Hamanofce7c7e2008-07-02 03:06:38326<em>git merge</em> &lt;msg&gt; HEAD &lt;remote&gt;&#8230;</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23327</div>
Junio C Hamanoba4b9282008-07-06 05:20:31328<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23329<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31330<div class="para"><p>This is the top-level interface to the merge machinery
331which drives multiple merge strategy scripts.</p></div>
332<div class="para"><p>The second syntax (&lt;msg&gt; <tt>HEAD</tt> &lt;remote&gt;) is supported for
Junio C Hamano1974bf22007-10-31 05:57:20333historical reasons. Do not use it from the command line or in
Junio C Hamanoba4b9282008-07-06 05:20:31334new scripts. It is the same as <tt>git merge -m &lt;msg&gt; &lt;remote&gt;</tt>.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23335</div>
Junio C Hamanoba4b9282008-07-06 05:20:31336<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23337<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31338<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23339<dt>
Junio C Hamano610d1762008-11-28 06:27:13340-q
341</dt>
342<dt>
343--quiet
344</dt>
345<dd>
346<p>
347 Operate quietly.
348</p>
349</dd>
350<dt>
351-v
352</dt>
353<dt>
354--verbose
355</dt>
356<dd>
357<p>
358 Be verbose.
359</p>
360</dd>
361<dt>
Junio C Hamano6d76d612008-05-09 05:46:08362--stat
Junio C Hamano591dc6a2007-05-29 09:18:19363</dt>
364<dd>
365<p>
366 Show a diffstat at the end of the merge. The diffstat is also
Junio C Hamano6d76d612008-05-09 05:46:08367 controlled by the configuration option merge.stat.
Junio C Hamano591dc6a2007-05-29 09:18:19368</p>
369</dd>
370<dt>
Junio C Hamanoeb415992008-06-08 22:49:47371-n
372</dt>
373<dt>
374--no-stat
Junio C Hamano1a4e8412005-12-27 08:17:23375</dt>
376<dd>
377<p>
Junio C Hamanoec87f522008-12-10 08:35:25378 Do not show a diffstat at the end of the merge.
Junio C Hamano1a4e8412005-12-27 08:17:23379</p>
380</dd>
381<dt>
Junio C Hamanoeb415992008-06-08 22:49:47382--summary
383</dt>
384<dt>
385--no-summary
Junio C Hamano6d76d612008-05-09 05:46:08386</dt>
387<dd>
388<p>
389 Synonyms to --stat and --no-stat; these are deprecated and will be
390 removed in the future.
391</p>
392</dd>
393<dt>
394--log
395</dt>
396<dd>
397<p>
398 In addition to branch names, populate the log message with
399 one-line descriptions from the actual commits that are being
400 merged.
401</p>
402</dd>
403<dt>
404--no-log
405</dt>
406<dd>
407<p>
408 Do not list one-line descriptions from the actual commits being
409 merged.
410</p>
411</dd>
412<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23413--no-commit
414</dt>
415<dd>
416<p>
417 Perform the merge but pretend the merge failed and do
418 not autocommit, to give the user a chance to inspect and
419 further tweak the merge result before committing.
420</p>
421</dd>
422<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53423--commit
424</dt>
425<dd>
426<p>
427 Perform the merge and commit the result. This option can
428 be used to override --no-commit.
429</p>
430</dd>
431<dt>
Junio C Hamano3901ffb2006-06-26 23:46:53432--squash
433</dt>
434<dd>
435<p>
436 Produce the working tree and index state as if a real
437 merge happened, but do not actually make a commit or
438 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
439 cause the next <tt>git commit</tt> command to create a merge
440 commit. This allows you to create a single commit on
441 top of the current branch whose effect is the same as
442 merging another branch (or more in case of an octopus).
443</p>
444</dd>
445<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53446--no-squash
447</dt>
448<dd>
449<p>
450 Perform the merge and commit the result. This option can
451 be used to override --squash.
452</p>
453</dd>
454<dt>
455--no-ff
456</dt>
457<dd>
458<p>
459 Generate a merge commit even if the merge resolved as a
460 fast-forward.
461</p>
462</dd>
463<dt>
464--ff
465</dt>
466<dd>
467<p>
468 Do not generate a merge commit if the merge resolved as
469 a fast-forward, only update the branch pointer. This is
470 the default behavior of git-merge.
471</p>
472</dd>
473<dt>
Junio C Hamanoeb415992008-06-08 22:49:47474-s &lt;strategy&gt;
475</dt>
476<dt>
477--strategy=&lt;strategy&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23478</dt>
479<dd>
480<p>
481 Use the given merge strategy; can be supplied more than
482 once to specify them in the order they should be tried.
483 If there is no <tt>-s</tt> option, a built-in list of strategies
Junio C Hamanoba4b9282008-07-06 05:20:31484 is used instead (<em>git-merge-recursive</em> when merging a single
485 head, <em>git-merge-octopus</em> otherwise).
Junio C Hamano1a4e8412005-12-27 08:17:23486</p>
487</dd>
488<dt>
Junio C Hamano1974bf22007-10-31 05:57:20489-m &lt;msg&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23490</dt>
491<dd>
492<p>
493 The commit message to be used for the merge commit (in case
Junio C Hamanoba4b9282008-07-06 05:20:31494 it is created). The <em>git-fmt-merge-msg</em> script can be used
495 to give a good default for automated <em>git-merge</em> invocations.
Junio C Hamano1a4e8412005-12-27 08:17:23496</p>
497</dd>
498<dt>
Junio C Hamano9e395072008-07-31 22:11:21499&lt;remote&gt;&#8230;
Junio C Hamano1a4e8412005-12-27 08:17:23500</dt>
501<dd>
502<p>
Junio C Hamano9e395072008-07-31 22:11:21503 Other branch heads to merge into our branch. You need at
Junio C Hamano1a4e8412005-12-27 08:17:23504 least one &lt;remote&gt;. Specifying more than one &lt;remote&gt;
505 obviously means you are trying an Octopus.
506</p>
507</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31508</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23509</div>
Junio C Hamanoba4b9282008-07-06 05:20:31510<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23511<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31512<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23513<dt>
514resolve
515</dt>
516<dd>
517<p>
518 This can only resolve two heads (i.e. the current branch
519 and another branch you pulled from) using 3-way merge
520 algorithm. It tries to carefully detect criss-cross
521 merge ambiguities and is considered generally safe and
522 fast.
523</p>
524</dd>
525<dt>
526recursive
527</dt>
528<dd>
529<p>
530 This can only resolve two heads using 3-way merge
531 algorithm. When there are more than one common
532 ancestors that can be used for 3-way merge, it creates a
533 merged tree of the common ancestors and uses that as
534 the reference tree for the 3-way merge. This has been
535 reported to result in fewer merge conflicts without
536 causing mis-merges by tests done on actual merge commits
537 taken from Linux 2.6 kernel development history.
538 Additionally this can detect and handle merges involving
539 renames. This is the default merge strategy when
540 pulling or merging one branch.
541</p>
542</dd>
543<dt>
544octopus
545</dt>
546<dd>
547<p>
548 This resolves more than two-head case, but refuses to do
549 complex merge that needs manual resolution. It is
550 primarily meant to be used for bundling topic branch
551 heads together. This is the default merge strategy when
552 pulling or merging more than one branches.
553</p>
554</dd>
555<dt>
556ours
557</dt>
558<dd>
559<p>
560 This resolves any number of heads, but the result of the
561 merge is always the current branch head. It is meant to
562 be used to supersede old development history of side
563 branches.
564</p>
565</dd>
Junio C Hamanoe6c92032008-03-19 09:24:34566<dt>
567subtree
568</dt>
569<dd>
570<p>
571 This is a modified recursive strategy. When merging trees A and
572 B, if B corresponds to a subtree of A, B is first adjusted to
573 match the tree structure of A, instead of reading the trees at
574 the same level. This adjustment is also done to the common
575 ancestor tree.
576</p>
577</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31578</dl></div>
579<div class="para"><p>If you tried a merge which resulted in a complex conflicts and
580would want to start over, you can recover with <em>git-reset</em>.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23581</div>
Junio C Hamanoba4b9282008-07-06 05:20:31582<h2 id="_configuration">CONFIGURATION</h2>
Junio C Hamano1e6e0062007-07-13 05:33:25583<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31584<div class="vlist"><dl>
Junio C Hamano1e6e0062007-07-13 05:33:25585<dt>
Junio C Hamano4653c6f2008-11-26 22:50:20586merge.conflictstyle
Junio C Hamano1e6e0062007-07-13 05:33:25587</dt>
588<dd>
589<p>
Junio C Hamano4653c6f2008-11-26 22:50:20590 Specify the style in which conflicted hunks are written out to
591 working tree files upon merge. The default is "merge", which
Junio C Hamanoec87f522008-12-10 08:35:25592 shows a <tt>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</tt> conflict marker, changes made by one side,
593 a <tt>=======</tt> marker, changes made by the other side, and then
594 a <tt>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</tt> marker. An alternate style, "diff3", adds a <tt>|||||||</tt>
595 marker and the original text before the <tt>=======</tt> marker.
Junio C Hamano6d76d612008-05-09 05:46:08596</p>
597</dd>
598<dt>
599merge.log
600</dt>
601<dd>
602<p>
603 Whether to include summaries of merged commits in newly created
604 merge commit messages. False by default.
605</p>
606</dd>
607<dt>
Junio C Hamano2fbcd212008-05-14 22:26:07608merge.renameLimit
609</dt>
610<dd>
611<p>
612 The number of files to consider when performing rename detection
613 during a merge; if not specified, defaults to the value of
614 diff.renameLimit.
615</p>
616</dd>
617<dt>
Junio C Hamano4653c6f2008-11-26 22:50:20618merge.stat
619</dt>
620<dd>
621<p>
622 Whether to print the diffstat between ORIG_HEAD and the merge result
623 at the end of the merge. True by default.
624</p>
625</dd>
626<dt>
Junio C Hamano6d76d612008-05-09 05:46:08627merge.tool
628</dt>
629<dd>
630<p>
631 Controls which merge resolution program is used by
632 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "kdiff3",
633 "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
634 "opendiff". Any other value is treated is custom merge tool
Junio C Hamanocb1c44f2008-08-06 06:19:33635 and there must be a corresponding mergetool.&lt;tool&gt;.cmd option.
Junio C Hamano1e6e0062007-07-13 05:33:25636</p>
637</dd>
638<dt>
639merge.verbosity
640</dt>
641<dd>
642<p>
643 Controls the amount of output shown by the recursive merge
644 strategy. Level 0 outputs nothing except a final error
645 message if conflicts were detected. Level 1 outputs only
646 conflicts, 2 outputs conflicts and file changes. Level 5 and
647 above outputs debugging information. The default is level 2.
Junio C Hamanoec87f522008-12-10 08:35:25648 Can be overridden by the <em>GIT_MERGE_VERBOSITY</em> environment variable.
Junio C Hamano1e6e0062007-07-13 05:33:25649</p>
650</dd>
Junio C Hamano1b50ce92007-10-03 12:05:53651<dt>
Junio C Hamano6d76d612008-05-09 05:46:08652merge.&lt;driver&gt;.name
653</dt>
654<dd>
655<p>
Junio C Hamanoec87f522008-12-10 08:35:25656 Defines a human-readable name for a custom low-level
Junio C Hamano6d76d612008-05-09 05:46:08657 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
658</p>
659</dd>
660<dt>
661merge.&lt;driver&gt;.driver
662</dt>
663<dd>
664<p>
665 Defines the command that implements a custom low-level
666 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
667</p>
668</dd>
669<dt>
670merge.&lt;driver&gt;.recursive
671</dt>
672<dd>
673<p>
674 Names a low-level merge driver to be used when
675 performing an internal merge between common ancestors.
676 See <a href="gitattributes.html">gitattributes(5)</a> for details.
677</p>
678</dd>
679<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53680branch.&lt;name&gt;.mergeoptions
681</dt>
682<dd>
683<p>
684 Sets default options for merging into branch &lt;name&gt;. The syntax and
Junio C Hamanoba4b9282008-07-06 05:20:31685 supported options are equal to that of <em>git-merge</em>, but option values
Junio C Hamano1b50ce92007-10-03 12:05:53686 containing whitespace characters are currently not supported.
687</p>
688</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31689</dl></div>
Junio C Hamano1e6e0062007-07-13 05:33:25690</div>
Junio C Hamanoba4b9282008-07-06 05:20:31691<h2 id="_how_merge_works">HOW MERGE WORKS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23692<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31693<div class="para"><p>A merge is always between the current <tt>HEAD</tt> and one or more
Junio C Hamano3b022a52008-03-04 12:06:24694commits (usually, branch head or tag), and the index file must
Junio C Hamano915cd9b2008-07-20 01:24:17695match the tree of <tt>HEAD</tt> commit (i.e. the contents of the last commit)
696when it starts out. In other words, <tt>git diff --cached HEAD</tt> must
697report no changes. (One exception is when the changed index
698entries are already in the same state that would result from
699the merge anyway.)</p></div>
700<div class="para"><p>Three kinds of merge can happen:</p></div>
701<div class="ilist"><ul>
702<li>
703<p>
704The merged commit is already contained in <tt>HEAD</tt>. This is the
705 simplest case, called "Already up-to-date."
706</p>
707</li>
708<li>
709<p>
710<tt>HEAD</tt> is already contained in the merged commit. This is the
Junio C Hamanoec87f522008-12-10 08:35:25711 most common case especially when invoked from <em>git pull</em>:
712 you are tracking an upstream repository, have committed no local
Junio C Hamano915cd9b2008-07-20 01:24:17713 changes and now you want to update to a newer upstream revision.
Junio C Hamanoec87f522008-12-10 08:35:25714 Your <tt>HEAD</tt> (and the index) is updated to point at the merged
Junio C Hamano915cd9b2008-07-20 01:24:17715 commit, without creating an extra merge commit. This is
716 called "Fast-forward".
717</p>
718</li>
719<li>
720<p>
721Both the merged commit and <tt>HEAD</tt> are independent and must be
Junio C Hamanoec87f522008-12-10 08:35:25722 tied together by a merge commit that has both of them as its parents.
Junio C Hamano915cd9b2008-07-20 01:24:17723 The rest of this section describes this "True merge" case.
724</p>
725</li>
726</ul></div>
727<div class="para"><p>The chosen merge strategy merges the two commits into a single
728new source tree.
Junio C Hamanoec87f522008-12-10 08:35:25729When things merge cleanly, this is what happens:</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31730<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:23731<li>
732<p>
Junio C Hamano092f5f02007-08-02 07:23:38733The results are updated both in the index file and in your
734 working tree;
Junio C Hamano1a4e8412005-12-27 08:17:23735</p>
736</li>
737<li>
738<p>
Junio C Hamano092f5f02007-08-02 07:23:38739Index file is written out as a tree;
Junio C Hamano1a4e8412005-12-27 08:17:23740</p>
741</li>
742<li>
743<p>
Junio C Hamano092f5f02007-08-02 07:23:38744The tree gets committed; and
Junio C Hamano1a4e8412005-12-27 08:17:23745</p>
746</li>
747<li>
748<p>
Junio C Hamano092f5f02007-08-02 07:23:38749The <tt>HEAD</tt> pointer gets advanced.
Junio C Hamano1a4e8412005-12-27 08:17:23750</p>
751</li>
Junio C Hamanoba4b9282008-07-06 05:20:31752</ol></div>
753<div class="para"><p>Because of 2., we require that the original state of the index
Junio C Hamanoec87f522008-12-10 08:35:25754file matches exactly the current <tt>HEAD</tt> commit; otherwise we
Junio C Hamano1a4e8412005-12-27 08:17:23755will write out your local changes already registered in your
756index file along with the merge result, which is not good.
Junio C Hamanoec87f522008-12-10 08:35:25757Because 1. involves only those paths differing between your
Junio C Hamano1a4e8412005-12-27 08:17:23758branch and the remote branch you are pulling from during the
759merge (which is typically a fraction of the whole tree), you can
760have local modifications in your working tree as long as they do
Junio C Hamanoba4b9282008-07-06 05:20:31761not overlap with what the merge updates.</p></div>
Junio C Hamanoec87f522008-12-10 08:35:25762<div class="para"><p>When there are conflicts, the following happens:</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31763<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:23764<li>
765<p>
766<tt>HEAD</tt> stays the same.
767</p>
768</li>
769<li>
770<p>
771Cleanly merged paths are updated both in the index file and
772 in your working tree.
773</p>
774</li>
775<li>
776<p>
777For conflicting paths, the index file records up to three
778 versions; stage1 stores the version from the common ancestor,
779 stage2 from <tt>HEAD</tt>, and stage3 from the remote branch (you
Junio C Hamanofce7c7e2008-07-02 03:06:38780 can inspect the stages with <tt>git ls-files -u</tt>). The working
Junio C Hamanoec87f522008-12-10 08:35:25781 tree files contain the result of the "merge" program; i.e. 3-way
782 merge results with familiar conflict markers <tt>&lt;&lt;&lt; === &gt;&gt;&gt;</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23783</p>
784</li>
785<li>
786<p>
787No other changes are done. In particular, the local
788 modifications you had before you started merge will stay the
789 same and the index entries for them stay as they were,
790 i.e. matching <tt>HEAD</tt>.
791</p>
792</li>
Junio C Hamanoba4b9282008-07-06 05:20:31793</ol></div>
Junio C Hamanoa476efa2008-10-10 15:31:42794</div>
795<h2 id="_how_conflicts_are_presented">HOW CONFLICTS ARE PRESENTED</h2>
796<div class="sectionbody">
797<div class="para"><p>During a merge, the working tree files are updated to reflect the result
798of the merge. Among the changes made to the common ancestor's version,
799non-overlapping ones (that is, you changed an area of the file while the
800other side left that area intact, or vice versa) are incorporated in the
801final result verbatim. When both sides made changes to the same area,
802however, git cannot randomly pick one side over the other, and asks you to
803resolve it by leaving what both sides did to that area.</p></div>
804<div class="para"><p>By default, git uses the same style as that is used by "merge" program
805from the RCS suite to present such a conflicted hunk, like this:</p></div>
806<div class="listingblock">
807<div class="content">
808<pre><tt>Here are lines that are either unchanged from the common
809ancestor, or cleanly resolved because only one side changed.
810&lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
811Conflict resolution is hard;
812let's go shopping.
813=======
814Git makes conflict resolution easy.
815&gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
816And here is another line that is cleanly resolved or unmodified.</tt></pre>
817</div></div>
Junio C Hamanoec87f522008-12-10 08:35:25818<div class="para"><p>The area where a pair of conflicting changes happened is marked with markers
Junio C Hamanoea82cff2009-03-18 01:54:48819<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>
Junio C Hamanoec87f522008-12-10 08:35:25820is typically your side, and the part afterwards is typically their side.</p></div>
821<div class="para"><p>The default format does not show what the original said in the conflicting
822area. You cannot tell how many lines are deleted and replaced with
823Barbie's remark on your side. The only thing you can tell is that your
Junio C Hamanoa476efa2008-10-10 15:31:42824side wants to say it is hard and you'd prefer to go shopping, while the
825other side wants to claim it is easy.</p></div>
826<div class="para"><p>An alternative style can be used by setting the "merge.conflictstyle"
827configuration variable to "diff3". In "diff3" style, the above conflict
828may look like this:</p></div>
829<div class="listingblock">
830<div class="content">
831<pre><tt>Here are lines that are either unchanged from the common
832ancestor, or cleanly resolved because only one side changed.
833&lt;&lt;&lt;&lt;&lt;&lt;&lt; yours:sample.txt
834Conflict resolution is hard;
835let's go shopping.
836|||||||
837Conflict resolution is hard.
838=======
839Git makes conflict resolution easy.
840&gt;&gt;&gt;&gt;&gt;&gt;&gt; theirs:sample.txt
841And here is another line that is cleanly resolved or unmodified.</tt></pre>
842</div></div>
Junio C Hamanoea82cff2009-03-18 01:54:48843<div class="para"><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
844another <tt>|||||||</tt> marker that is followed by the original text. You can
Junio C Hamanoa476efa2008-10-10 15:31:42845tell that the original just stated a fact, and your side simply gave in to
846that statement and gave up, while the other side tried to have a more
847positive attitude. You can sometimes come up with a better resolution by
848viewing the original.</p></div>
849</div>
850<h2 id="_how_to_resolve_conflicts">HOW TO RESOLVE CONFLICTS</h2>
851<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31852<div class="para"><p>After seeing a conflict, you can do two things:</p></div>
853<div class="ilist"><ul>
Junio C Hamano1a4e8412005-12-27 08:17:23854<li>
855<p>
Junio C Hamanoec87f522008-12-10 08:35:25856Decide not to merge. The only clean-ups you need are to reset
Junio C Hamano1a4e8412005-12-27 08:17:23857 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
Junio C Hamano915cd9b2008-07-20 01:24:17858 up working tree changes made by 2. and 3.; <em>git-reset --hard</em> can
Junio C Hamano1a4e8412005-12-27 08:17:23859 be used for this.
860</p>
861</li>
862<li>
863<p>
Junio C Hamano043628e2008-08-24 03:34:11864Resolve the conflicts. Git will mark the conflicts in
865 the working tree. Edit the files into shape and
Junio C Hamanoec87f522008-12-10 08:35:25866 <em>git-add</em> them to the index. Use <em>git-commit</em> to seal the deal.
Junio C Hamano043628e2008-08-24 03:34:11867</p>
868</li>
869</ul></div>
870<div class="para"><p>You can work through the conflict with a number of tools:</p></div>
871<div class="ilist"><ul>
872<li>
873<p>
874Use a mergetool. <em>git mergetool</em> to launch a graphical
875 mergetool which will work you through the merge.
876</p>
877</li>
878<li>
879<p>
880Look at the diffs. <em>git diff</em> will show a three-way diff,
881 highlighting changes from both the HEAD and remote versions.
882</p>
883</li>
884<li>
885<p>
886Look at the diffs on their own. <em>git log --merge -p &lt;path&gt;</em>
887 will show diffs first for the HEAD version and then the
888 remote version.
889</p>
890</li>
891<li>
892<p>
893Look at the originals. <em>git show :1:filename</em> shows the
894 common ancestor, <em>git show :2:filename</em> shows the HEAD
895 version and <em>git show :3:filename</em> shows the remote version.
Junio C Hamano1a4e8412005-12-27 08:17:23896</p>
897</li>
Junio C Hamanoba4b9282008-07-06 05:20:31898</ul></div>
Junio C Hamano1a4e8412005-12-27 08:17:23899</div>
Junio C Hamanoba4b9282008-07-06 05:20:31900<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23901<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31902<div class="para"><p><a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>, <a href="git-pull.html">git-pull(1)</a>,
Junio C Hamanofce7c7e2008-07-02 03:06:38903<a href="gitattributes.html">gitattributes(5)</a>,
904<a href="git-reset.html">git-reset(1)</a>,
905<a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
906<a href="git-add.html">git-add(1)</a>, <a href="git-rm.html">git-rm(1)</a>,
Junio C Hamanoba4b9282008-07-06 05:20:31907<a href="git-mergetool.html">git-mergetool(1)</a></p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23908</div>
Junio C Hamanoba4b9282008-07-06 05:20:31909<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23910<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44911<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23912</div>
Junio C Hamanoba4b9282008-07-06 05:20:31913<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23914<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31915<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23916</div>
Junio C Hamanoba4b9282008-07-06 05:20:31917<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23918<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31919<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23920</div>
921<div id="footer">
922<div id="footer-text">
Junio C Hamanoea82cff2009-03-18 01:54:48923Last updated 2009-03-18 01:54:21 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23924</div>
925</div>
926</body>
927</html>