blob: 3ebfdcafbd0a75714c11a50b1441e9edc9a84aaa [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 Hamano6d76d612008-05-09 05:46:08340--stat
Junio C Hamano591dc6a2007-05-29 09:18:19341</dt>
342<dd>
343<p>
344 Show a diffstat at the end of the merge. The diffstat is also
Junio C Hamano6d76d612008-05-09 05:46:08345 controlled by the configuration option merge.stat.
Junio C Hamano591dc6a2007-05-29 09:18:19346</p>
347</dd>
348<dt>
Junio C Hamanoeb415992008-06-08 22:49:47349-n
350</dt>
351<dt>
352--no-stat
Junio C Hamano1a4e8412005-12-27 08:17:23353</dt>
354<dd>
355<p>
356 Do not show diffstat at the end of the merge.
357</p>
358</dd>
359<dt>
Junio C Hamanoeb415992008-06-08 22:49:47360--summary
361</dt>
362<dt>
363--no-summary
Junio C Hamano6d76d612008-05-09 05:46:08364</dt>
365<dd>
366<p>
367 Synonyms to --stat and --no-stat; these are deprecated and will be
368 removed in the future.
369</p>
370</dd>
371<dt>
372--log
373</dt>
374<dd>
375<p>
376 In addition to branch names, populate the log message with
377 one-line descriptions from the actual commits that are being
378 merged.
379</p>
380</dd>
381<dt>
382--no-log
383</dt>
384<dd>
385<p>
386 Do not list one-line descriptions from the actual commits being
387 merged.
388</p>
389</dd>
390<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23391--no-commit
392</dt>
393<dd>
394<p>
395 Perform the merge but pretend the merge failed and do
396 not autocommit, to give the user a chance to inspect and
397 further tweak the merge result before committing.
398</p>
399</dd>
400<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53401--commit
402</dt>
403<dd>
404<p>
405 Perform the merge and commit the result. This option can
406 be used to override --no-commit.
407</p>
408</dd>
409<dt>
Junio C Hamano3901ffb2006-06-26 23:46:53410--squash
411</dt>
412<dd>
413<p>
414 Produce the working tree and index state as if a real
415 merge happened, but do not actually make a commit or
416 move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to
417 cause the next <tt>git commit</tt> command to create a merge
418 commit. This allows you to create a single commit on
419 top of the current branch whose effect is the same as
420 merging another branch (or more in case of an octopus).
421</p>
422</dd>
423<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53424--no-squash
425</dt>
426<dd>
427<p>
428 Perform the merge and commit the result. This option can
429 be used to override --squash.
430</p>
431</dd>
432<dt>
433--no-ff
434</dt>
435<dd>
436<p>
437 Generate a merge commit even if the merge resolved as a
438 fast-forward.
439</p>
440</dd>
441<dt>
442--ff
443</dt>
444<dd>
445<p>
446 Do not generate a merge commit if the merge resolved as
447 a fast-forward, only update the branch pointer. This is
448 the default behavior of git-merge.
449</p>
450</dd>
451<dt>
Junio C Hamanoeb415992008-06-08 22:49:47452-s &lt;strategy&gt;
453</dt>
454<dt>
455--strategy=&lt;strategy&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23456</dt>
457<dd>
458<p>
459 Use the given merge strategy; can be supplied more than
460 once to specify them in the order they should be tried.
461 If there is no <tt>-s</tt> option, a built-in list of strategies
Junio C Hamanoba4b9282008-07-06 05:20:31462 is used instead (<em>git-merge-recursive</em> when merging a single
463 head, <em>git-merge-octopus</em> otherwise).
Junio C Hamano1a4e8412005-12-27 08:17:23464</p>
465</dd>
466<dt>
Junio C Hamano1974bf22007-10-31 05:57:20467-m &lt;msg&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23468</dt>
469<dd>
470<p>
471 The commit message to be used for the merge commit (in case
Junio C Hamanoba4b9282008-07-06 05:20:31472 it is created). The <em>git-fmt-merge-msg</em> script can be used
473 to give a good default for automated <em>git-merge</em> invocations.
Junio C Hamano1a4e8412005-12-27 08:17:23474</p>
475</dd>
476<dt>
Junio C Hamano9e395072008-07-31 22:11:21477&lt;remote&gt;&#8230;
Junio C Hamano1a4e8412005-12-27 08:17:23478</dt>
479<dd>
480<p>
Junio C Hamano9e395072008-07-31 22:11:21481 Other branch heads to merge into our branch. You need at
Junio C Hamano1a4e8412005-12-27 08:17:23482 least one &lt;remote&gt;. Specifying more than one &lt;remote&gt;
483 obviously means you are trying an Octopus.
484</p>
485</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31486</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23487</div>
Junio C Hamanoba4b9282008-07-06 05:20:31488<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23489<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31490<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23491<dt>
492resolve
493</dt>
494<dd>
495<p>
496 This can only resolve two heads (i.e. the current branch
497 and another branch you pulled from) using 3-way merge
498 algorithm. It tries to carefully detect criss-cross
499 merge ambiguities and is considered generally safe and
500 fast.
501</p>
502</dd>
503<dt>
504recursive
505</dt>
506<dd>
507<p>
508 This can only resolve two heads using 3-way merge
509 algorithm. When there are more than one common
510 ancestors that can be used for 3-way merge, it creates a
511 merged tree of the common ancestors and uses that as
512 the reference tree for the 3-way merge. This has been
513 reported to result in fewer merge conflicts without
514 causing mis-merges by tests done on actual merge commits
515 taken from Linux 2.6 kernel development history.
516 Additionally this can detect and handle merges involving
517 renames. This is the default merge strategy when
518 pulling or merging one branch.
519</p>
520</dd>
521<dt>
522octopus
523</dt>
524<dd>
525<p>
526 This resolves more than two-head case, but refuses to do
527 complex merge that needs manual resolution. It is
528 primarily meant to be used for bundling topic branch
529 heads together. This is the default merge strategy when
530 pulling or merging more than one branches.
531</p>
532</dd>
533<dt>
534ours
535</dt>
536<dd>
537<p>
538 This resolves any number of heads, but the result of the
539 merge is always the current branch head. It is meant to
540 be used to supersede old development history of side
541 branches.
542</p>
543</dd>
Junio C Hamanoe6c92032008-03-19 09:24:34544<dt>
545subtree
546</dt>
547<dd>
548<p>
549 This is a modified recursive strategy. When merging trees A and
550 B, if B corresponds to a subtree of A, B is first adjusted to
551 match the tree structure of A, instead of reading the trees at
552 the same level. This adjustment is also done to the common
553 ancestor tree.
554</p>
555</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31556</dl></div>
557<div class="para"><p>If you tried a merge which resulted in a complex conflicts and
558would want to start over, you can recover with <em>git-reset</em>.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23559</div>
Junio C Hamanoba4b9282008-07-06 05:20:31560<h2 id="_configuration">CONFIGURATION</h2>
Junio C Hamano1e6e0062007-07-13 05:33:25561<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31562<div class="vlist"><dl>
Junio C Hamano1e6e0062007-07-13 05:33:25563<dt>
Junio C Hamano6d76d612008-05-09 05:46:08564merge.stat
Junio C Hamano1e6e0062007-07-13 05:33:25565</dt>
566<dd>
567<p>
Junio C Hamano6d76d612008-05-09 05:46:08568 Whether to print the diffstat berween ORIG_HEAD and merge result
569 at the end of the merge. True by default.
570</p>
571</dd>
572<dt>
573merge.log
574</dt>
575<dd>
576<p>
577 Whether to include summaries of merged commits in newly created
578 merge commit messages. False by default.
579</p>
580</dd>
581<dt>
Junio C Hamano2fbcd212008-05-14 22:26:07582merge.renameLimit
583</dt>
584<dd>
585<p>
586 The number of files to consider when performing rename detection
587 during a merge; if not specified, defaults to the value of
588 diff.renameLimit.
589</p>
590</dd>
591<dt>
Junio C Hamano6d76d612008-05-09 05:46:08592merge.tool
593</dt>
594<dd>
595<p>
596 Controls which merge resolution program is used by
597 <a href="git-mergetool.html">git-mergetool(1)</a>. Valid built-in values are: "kdiff3",
598 "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
599 "opendiff". Any other value is treated is custom merge tool
600 and there must be a corresponing mergetool.&lt;tool&gt;.cmd option.
Junio C Hamano1e6e0062007-07-13 05:33:25601</p>
602</dd>
603<dt>
604merge.verbosity
605</dt>
606<dd>
607<p>
608 Controls the amount of output shown by the recursive merge
609 strategy. Level 0 outputs nothing except a final error
610 message if conflicts were detected. Level 1 outputs only
611 conflicts, 2 outputs conflicts and file changes. Level 5 and
612 above outputs debugging information. The default is level 2.
Junio C Hamano4fd58d42007-09-30 00:51:14613 Can be overridden by <em>GIT_MERGE_VERBOSITY</em> environment variable.
Junio C Hamano1e6e0062007-07-13 05:33:25614</p>
615</dd>
Junio C Hamano1b50ce92007-10-03 12:05:53616<dt>
Junio C Hamano6d76d612008-05-09 05:46:08617merge.&lt;driver&gt;.name
618</dt>
619<dd>
620<p>
621 Defines a human readable name for a custom low-level
622 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
623</p>
624</dd>
625<dt>
626merge.&lt;driver&gt;.driver
627</dt>
628<dd>
629<p>
630 Defines the command that implements a custom low-level
631 merge driver. See <a href="gitattributes.html">gitattributes(5)</a> for details.
632</p>
633</dd>
634<dt>
635merge.&lt;driver&gt;.recursive
636</dt>
637<dd>
638<p>
639 Names a low-level merge driver to be used when
640 performing an internal merge between common ancestors.
641 See <a href="gitattributes.html">gitattributes(5)</a> for details.
642</p>
643</dd>
644<dt>
Junio C Hamano1b50ce92007-10-03 12:05:53645branch.&lt;name&gt;.mergeoptions
646</dt>
647<dd>
648<p>
649 Sets default options for merging into branch &lt;name&gt;. The syntax and
Junio C Hamanoba4b9282008-07-06 05:20:31650 supported options are equal to that of <em>git-merge</em>, but option values
Junio C Hamano1b50ce92007-10-03 12:05:53651 containing whitespace characters are currently not supported.
652</p>
653</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31654</dl></div>
Junio C Hamano1e6e0062007-07-13 05:33:25655</div>
Junio C Hamanoba4b9282008-07-06 05:20:31656<h2 id="_how_merge_works">HOW MERGE WORKS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23657<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31658<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:24659commits (usually, branch head or tag), and the index file must
Junio C Hamano915cd9b2008-07-20 01:24:17660match the tree of <tt>HEAD</tt> commit (i.e. the contents of the last commit)
661when it starts out. In other words, <tt>git diff --cached HEAD</tt> must
662report no changes. (One exception is when the changed index
663entries are already in the same state that would result from
664the merge anyway.)</p></div>
665<div class="para"><p>Three kinds of merge can happen:</p></div>
666<div class="ilist"><ul>
667<li>
668<p>
669The merged commit is already contained in <tt>HEAD</tt>. This is the
670 simplest case, called "Already up-to-date."
671</p>
672</li>
673<li>
674<p>
675<tt>HEAD</tt> is already contained in the merged commit. This is the
676 most common case especially when involved through <em>git pull</em>:
677 you are tracking an upstream repository, committed no local
678 changes and now you want to update to a newer upstream revision.
679 Your <tt>HEAD</tt> (and the index) is updated to at point the merged
680 commit, without creating an extra merge commit. This is
681 called "Fast-forward".
682</p>
683</li>
684<li>
685<p>
686Both the merged commit and <tt>HEAD</tt> are independent and must be
687 tied together by a merge commit that has them both as its parents.
688 The rest of this section describes this "True merge" case.
689</p>
690</li>
691</ul></div>
692<div class="para"><p>The chosen merge strategy merges the two commits into a single
693new source tree.
694When things cleanly merge, these things happen:</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31695<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:23696<li>
697<p>
Junio C Hamano092f5f02007-08-02 07:23:38698The results are updated both in the index file and in your
699 working tree;
Junio C Hamano1a4e8412005-12-27 08:17:23700</p>
701</li>
702<li>
703<p>
Junio C Hamano092f5f02007-08-02 07:23:38704Index file is written out as a tree;
Junio C Hamano1a4e8412005-12-27 08:17:23705</p>
706</li>
707<li>
708<p>
Junio C Hamano092f5f02007-08-02 07:23:38709The tree gets committed; and
Junio C Hamano1a4e8412005-12-27 08:17:23710</p>
711</li>
712<li>
713<p>
Junio C Hamano092f5f02007-08-02 07:23:38714The <tt>HEAD</tt> pointer gets advanced.
Junio C Hamano1a4e8412005-12-27 08:17:23715</p>
716</li>
Junio C Hamanoba4b9282008-07-06 05:20:31717</ol></div>
718<div class="para"><p>Because of 2., we require that the original state of the index
Junio C Hamano1a4e8412005-12-27 08:17:23719file to match exactly the current <tt>HEAD</tt> commit; otherwise we
720will write out your local changes already registered in your
721index file along with the merge result, which is not good.
722Because 1. involves only the paths different between your
723branch and the remote branch you are pulling from during the
724merge (which is typically a fraction of the whole tree), you can
725have local modifications in your working tree as long as they do
Junio C Hamanoba4b9282008-07-06 05:20:31726not overlap with what the merge updates.</p></div>
727<div class="para"><p>When there are conflicts, these things happen:</p></div>
728<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:23729<li>
730<p>
731<tt>HEAD</tt> stays the same.
732</p>
733</li>
734<li>
735<p>
736Cleanly merged paths are updated both in the index file and
737 in your working tree.
738</p>
739</li>
740<li>
741<p>
742For conflicting paths, the index file records up to three
743 versions; stage1 stores the version from the common ancestor,
744 stage2 from <tt>HEAD</tt>, and stage3 from the remote branch (you
Junio C Hamanofce7c7e2008-07-02 03:06:38745 can inspect the stages with <tt>git ls-files -u</tt>). The working
Junio C Hamano1a4e8412005-12-27 08:17:23746 tree files have the result of "merge" program; i.e. 3-way
747 merge result with familiar conflict markers <tt>&lt;&lt;&lt; === &gt;&gt;&gt;</tt>.
748</p>
749</li>
750<li>
751<p>
752No other changes are done. In particular, the local
753 modifications you had before you started merge will stay the
754 same and the index entries for them stay as they were,
755 i.e. matching <tt>HEAD</tt>.
756</p>
757</li>
Junio C Hamanoba4b9282008-07-06 05:20:31758</ol></div>
759<div class="para"><p>After seeing a conflict, you can do two things:</p></div>
760<div class="ilist"><ul>
Junio C Hamano1a4e8412005-12-27 08:17:23761<li>
762<p>
763Decide not to merge. The only clean-up you need are to reset
764 the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean
Junio C Hamano915cd9b2008-07-20 01:24:17765 up working tree changes made by 2. and 3.; <em>git-reset --hard</em> can
Junio C Hamano1a4e8412005-12-27 08:17:23766 be used for this.
767</p>
768</li>
769<li>
770<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38771Resolve the conflicts. <tt>git diff</tt> would report only the
Junio C Hamano915cd9b2008-07-20 01:24:17772 conflicting paths because of the above 2. and 3.
773 Edit the working tree files into a desirable shape
774 (<em>git mergetool</em> can ease this task), <em>git-add</em> or <em>git-rm</em>
Junio C Hamano1a4e8412005-12-27 08:17:23775 them, to make the index file contain what the merge result
Junio C Hamanoba4b9282008-07-06 05:20:31776 should be, and run <em>git-commit</em> to commit the result.
Junio C Hamano1a4e8412005-12-27 08:17:23777</p>
778</li>
Junio C Hamanoba4b9282008-07-06 05:20:31779</ul></div>
Junio C Hamano1a4e8412005-12-27 08:17:23780</div>
Junio C Hamanoba4b9282008-07-06 05:20:31781<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23782<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31783<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:38784<a href="gitattributes.html">gitattributes(5)</a>,
785<a href="git-reset.html">git-reset(1)</a>,
786<a href="git-diff.html">git-diff(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
787<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:31788<a href="git-mergetool.html">git-mergetool(1)</a></p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23789</div>
Junio C Hamanoba4b9282008-07-06 05:20:31790<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23791<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44792<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23793</div>
Junio C Hamanoba4b9282008-07-06 05:20:31794<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23795<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31796<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:23797</div>
Junio C Hamanoba4b9282008-07-06 05:20:31798<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23799<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31800<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23801</div>
802<div id="footer">
803<div id="footer-text">
Junio C Hamano9e395072008-07-31 22:11:21804Last updated 2008-07-31 22:10:20 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23805</div>
806</div>
807</body>
808</html>