Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 2 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Junio C Hamano | 3901ffb | 2006-06-26 23:46:53 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, h2, h3, h4, h5, h6 { |
| 35 | color: #527bbd; |
| 36 | font-family: sans-serif; |
| 37 | margin-top: 1.2em; |
| 38 | margin-bottom: 0.5em; |
| 39 | line-height: 1.3; |
| 40 | } |
| 41 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#footer { |
| 82 | font-family: sans-serif; |
| 83 | font-size: small; |
| 84 | border-top: 2px solid silver; |
| 85 | padding-top: 0.5em; |
| 86 | margin-top: 4.0em; |
| 87 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.title, caption.title { |
| 116 | font-family: sans-serif; |
| 117 | font-weight: bold; |
| 118 | text-align: left; |
| 119 | margin-top: 1.0em; |
| 120 | margin-bottom: 0.5em; |
| 121 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.admonitionblock .icon { |
| 156 | vertical-align: top; |
| 157 | font-size: 1.1em; |
| 158 | font-weight: bold; |
| 159 | text-decoration: underline; |
| 160 | color: #527bbd; |
| 161 | padding-right: 0.5em; |
| 162 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | include::./stylesheets/xhtml11-manpage.css[] |
| 230 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 231 | |
| 232 | div.sidebar-content { |
| 233 | background: #ffffee; |
| 234 | border: 1px solid silver; |
| 235 | padding: 0.5em; |
| 236 | } |
| 237 | div.sidebar-title, div.image-title { |
| 238 | font-family: sans-serif; |
| 239 | font-weight: bold; |
| 240 | margin-top: 0.0em; |
| 241 | margin-bottom: 0.5em; |
| 242 | } |
| 243 | |
| 244 | div.listingblock div.content { |
| 245 | border: 1px solid silver; |
| 246 | background: #f4f4f4; |
| 247 | padding: 0.5em; |
| 248 | } |
| 249 | |
| 250 | div.quoteblock-content { |
| 251 | padding-left: 2.0em; |
| 252 | } |
| 253 | |
| 254 | div.exampleblock-content { |
| 255 | border-left: 2px solid silver; |
| 256 | padding-left: 0.5em; |
| 257 | } |
| 258 | </style> |
| 259 | <title>git-merge(1)</title> |
| 260 | </head> |
| 261 | <body> |
| 262 | <div id="header"> |
| 263 | <h1> |
| 264 | git-merge(1) Manual Page |
| 265 | </h1> |
| 266 | <h2>NAME</h2> |
| 267 | <div class="sectionbody"> |
| 268 | <p>git-merge - |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 269 | Join two or more development histories together |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 270 | </p> |
| 271 | </div> |
| 272 | </div> |
| 273 | <h2>SYNOPSIS</h2> |
| 274 | <div class="sectionbody"> |
Junio C Hamano | ee6d961 | 2006-11-27 20:03:22 | [diff] [blame] | 275 | <div class="verseblock"> |
Junio C Hamano | 591dc6a | 2007-05-29 09:18:19 | [diff] [blame] | 276 | <div class="content"><em>git-merge</em> [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]… |
Junio C Hamano | 1974bf2 | 2007-10-31 05:57:20 | [diff] [blame] | 277 | [-m <msg>] <remote> <remote>… |
| 278 | <em>git-merge</em> <msg> HEAD <remote>…</div></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 279 | </div> |
| 280 | <h2>DESCRIPTION</h2> |
| 281 | <div class="sectionbody"> |
Junio C Hamano | ee6d961 | 2006-11-27 20:03:22 | [diff] [blame] | 282 | <p>This is the top-level interface to the merge machinery |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 283 | which drives multiple merge strategy scripts.</p> |
Junio C Hamano | 1974bf2 | 2007-10-31 05:57:20 | [diff] [blame] | 284 | <p>The second syntax (<msg> <tt>HEAD</tt> <remote>) is supported for |
| 285 | historical reasons. Do not use it from the command line or in |
| 286 | new scripts. It is the same as <tt>git merge -m <msg> <remote></tt>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 287 | </div> |
| 288 | <h2>OPTIONS</h2> |
| 289 | <div class="sectionbody"> |
| 290 | <dl> |
| 291 | <dt> |
Junio C Hamano | 591dc6a | 2007-05-29 09:18:19 | [diff] [blame] | 292 | --summary |
| 293 | </dt> |
| 294 | <dd> |
| 295 | <p> |
| 296 | Show a diffstat at the end of the merge. The diffstat is also |
| 297 | controlled by the configuration option merge.diffstat. |
| 298 | </p> |
| 299 | </dd> |
| 300 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 301 | -n, --no-summary |
| 302 | </dt> |
| 303 | <dd> |
| 304 | <p> |
| 305 | Do not show diffstat at the end of the merge. |
| 306 | </p> |
| 307 | </dd> |
| 308 | <dt> |
| 309 | --no-commit |
| 310 | </dt> |
| 311 | <dd> |
| 312 | <p> |
| 313 | Perform the merge but pretend the merge failed and do |
| 314 | not autocommit, to give the user a chance to inspect and |
| 315 | further tweak the merge result before committing. |
| 316 | </p> |
| 317 | </dd> |
| 318 | <dt> |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 319 | --commit |
| 320 | </dt> |
| 321 | <dd> |
| 322 | <p> |
| 323 | Perform the merge and commit the result. This option can |
| 324 | be used to override --no-commit. |
| 325 | </p> |
| 326 | </dd> |
| 327 | <dt> |
Junio C Hamano | 3901ffb | 2006-06-26 23:46:53 | [diff] [blame] | 328 | --squash |
| 329 | </dt> |
| 330 | <dd> |
| 331 | <p> |
| 332 | Produce the working tree and index state as if a real |
| 333 | merge happened, but do not actually make a commit or |
| 334 | move the <tt>HEAD</tt>, nor record <tt>$GIT_DIR/MERGE_HEAD</tt> to |
| 335 | cause the next <tt>git commit</tt> command to create a merge |
| 336 | commit. This allows you to create a single commit on |
| 337 | top of the current branch whose effect is the same as |
| 338 | merging another branch (or more in case of an octopus). |
| 339 | </p> |
| 340 | </dd> |
| 341 | <dt> |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 342 | --no-squash |
| 343 | </dt> |
| 344 | <dd> |
| 345 | <p> |
| 346 | Perform the merge and commit the result. This option can |
| 347 | be used to override --squash. |
| 348 | </p> |
| 349 | </dd> |
| 350 | <dt> |
| 351 | --no-ff |
| 352 | </dt> |
| 353 | <dd> |
| 354 | <p> |
| 355 | Generate a merge commit even if the merge resolved as a |
| 356 | fast-forward. |
| 357 | </p> |
| 358 | </dd> |
| 359 | <dt> |
| 360 | --ff |
| 361 | </dt> |
| 362 | <dd> |
| 363 | <p> |
| 364 | Do not generate a merge commit if the merge resolved as |
| 365 | a fast-forward, only update the branch pointer. This is |
| 366 | the default behavior of git-merge. |
| 367 | </p> |
| 368 | </dd> |
| 369 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 370 | -s <strategy>, --strategy=<strategy> |
| 371 | </dt> |
| 372 | <dd> |
| 373 | <p> |
| 374 | Use the given merge strategy; can be supplied more than |
| 375 | once to specify them in the order they should be tried. |
| 376 | If there is no <tt>-s</tt> option, a built-in list of strategies |
| 377 | is used instead (<tt>git-merge-recursive</tt> when merging a single |
| 378 | head, <tt>git-merge-octopus</tt> otherwise). |
| 379 | </p> |
| 380 | </dd> |
| 381 | <dt> |
Junio C Hamano | 1974bf2 | 2007-10-31 05:57:20 | [diff] [blame] | 382 | -m <msg> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 383 | </dt> |
| 384 | <dd> |
| 385 | <p> |
| 386 | The commit message to be used for the merge commit (in case |
| 387 | it is created). The <tt>git-fmt-merge-msg</tt> script can be used |
| 388 | to give a good default for automated <tt>git-merge</tt> invocations. |
| 389 | </p> |
| 390 | </dd> |
| 391 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 392 | <remote> |
| 393 | </dt> |
| 394 | <dd> |
| 395 | <p> |
Junio C Hamano | ee6d961 | 2006-11-27 20:03:22 | [diff] [blame] | 396 | Other branch head merged into our branch. You need at |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 397 | least one <remote>. Specifying more than one <remote> |
| 398 | obviously means you are trying an Octopus. |
| 399 | </p> |
| 400 | </dd> |
| 401 | </dl> |
| 402 | </div> |
| 403 | <h2>MERGE STRATEGIES</h2> |
| 404 | <div class="sectionbody"> |
| 405 | <dl> |
| 406 | <dt> |
| 407 | resolve |
| 408 | </dt> |
| 409 | <dd> |
| 410 | <p> |
| 411 | This can only resolve two heads (i.e. the current branch |
| 412 | and another branch you pulled from) using 3-way merge |
| 413 | algorithm. It tries to carefully detect criss-cross |
| 414 | merge ambiguities and is considered generally safe and |
| 415 | fast. |
| 416 | </p> |
| 417 | </dd> |
| 418 | <dt> |
| 419 | recursive |
| 420 | </dt> |
| 421 | <dd> |
| 422 | <p> |
| 423 | This can only resolve two heads using 3-way merge |
| 424 | algorithm. When there are more than one common |
| 425 | ancestors that can be used for 3-way merge, it creates a |
| 426 | merged tree of the common ancestors and uses that as |
| 427 | the reference tree for the 3-way merge. This has been |
| 428 | reported to result in fewer merge conflicts without |
| 429 | causing mis-merges by tests done on actual merge commits |
| 430 | taken from Linux 2.6 kernel development history. |
| 431 | Additionally this can detect and handle merges involving |
| 432 | renames. This is the default merge strategy when |
| 433 | pulling or merging one branch. |
| 434 | </p> |
| 435 | </dd> |
| 436 | <dt> |
| 437 | octopus |
| 438 | </dt> |
| 439 | <dd> |
| 440 | <p> |
| 441 | This resolves more than two-head case, but refuses to do |
| 442 | complex merge that needs manual resolution. It is |
| 443 | primarily meant to be used for bundling topic branch |
| 444 | heads together. This is the default merge strategy when |
| 445 | pulling or merging more than one branches. |
| 446 | </p> |
| 447 | </dd> |
| 448 | <dt> |
| 449 | ours |
| 450 | </dt> |
| 451 | <dd> |
| 452 | <p> |
| 453 | This resolves any number of heads, but the result of the |
| 454 | merge is always the current branch head. It is meant to |
| 455 | be used to supersede old development history of side |
| 456 | branches. |
| 457 | </p> |
| 458 | </dd> |
| 459 | </dl> |
| 460 | <p>If you tried a merge which resulted in a complex conflicts and |
| 461 | would want to start over, you can recover with |
| 462 | <a href="git-reset.html">git-reset(1)</a>.</p> |
| 463 | </div> |
Junio C Hamano | 1e6e006 | 2007-07-13 05:33:25 | [diff] [blame] | 464 | <h2>CONFIGURATION</h2> |
| 465 | <div class="sectionbody"> |
| 466 | <dl> |
| 467 | <dt> |
| 468 | merge.summary |
| 469 | </dt> |
| 470 | <dd> |
| 471 | <p> |
| 472 | Whether to include summaries of merged commits in newly |
| 473 | created merge commit. False by default. |
| 474 | </p> |
| 475 | </dd> |
| 476 | <dt> |
| 477 | merge.verbosity |
| 478 | </dt> |
| 479 | <dd> |
| 480 | <p> |
| 481 | Controls the amount of output shown by the recursive merge |
| 482 | strategy. Level 0 outputs nothing except a final error |
| 483 | message if conflicts were detected. Level 1 outputs only |
| 484 | conflicts, 2 outputs conflicts and file changes. Level 5 and |
| 485 | above outputs debugging information. The default is level 2. |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 486 | Can be overridden by <em>GIT_MERGE_VERBOSITY</em> environment variable. |
Junio C Hamano | 1e6e006 | 2007-07-13 05:33:25 | [diff] [blame] | 487 | </p> |
| 488 | </dd> |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 489 | <dt> |
| 490 | branch.<name>.mergeoptions |
| 491 | </dt> |
| 492 | <dd> |
| 493 | <p> |
| 494 | Sets default options for merging into branch <name>. The syntax and |
| 495 | supported options are equal to that of git-merge, but option values |
| 496 | containing whitespace characters are currently not supported. |
| 497 | </p> |
| 498 | </dd> |
Junio C Hamano | 1e6e006 | 2007-07-13 05:33:25 | [diff] [blame] | 499 | </dl> |
| 500 | </div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 501 | <h2>HOW MERGE WORKS</h2> |
| 502 | <div class="sectionbody"> |
| 503 | <p>A merge is always between the current <tt>HEAD</tt> and one or more |
| 504 | remote branch heads, and the index file must exactly match the |
| 505 | tree of <tt>HEAD</tt> commit (i.e. the contents of the last commit) when |
| 506 | it happens. In other words, <tt>git-diff --cached HEAD</tt> must |
| 507 | report no changes.</p> |
| 508 | <div class="admonitionblock"> |
| 509 | <table><tr> |
| 510 | <td class="icon"> |
| 511 | <div class="title">Note</div> |
| 512 | </td> |
| 513 | <td class="content">This is a bit of lie. In certain special cases, your index are |
| 514 | allowed to be different from the tree of <tt>HEAD</tt> commit. The most |
| 515 | notable case is when your <tt>HEAD</tt> commit is already ahead of what |
| 516 | is being merged, in which case your index can have arbitrary |
| 517 | difference from your <tt>HEAD</tt> commit. Otherwise, your index entries |
| 518 | are allowed have differences from your <tt>HEAD</tt> commit that match |
| 519 | the result of trivial merge (e.g. you received the same patch |
| 520 | from external source to produce the same result as what you are |
| 521 | merging). For example, if a path did not exist in the common |
| 522 | ancestor and your head commit but exists in the tree you are |
| 523 | merging into your repository, and if you already happen to have |
| 524 | that path exactly in your index, the merge does not have to |
| 525 | fail.</td> |
| 526 | </tr></table> |
| 527 | </div> |
| 528 | <p>Otherwise, merge will refuse to do any harm to your repository |
| 529 | (that is, it may fetch the objects from remote, and it may even |
| 530 | update the local branch used to keep track of the remote branch |
| 531 | with <tt>git pull remote rbranch:lbranch</tt>, but your working tree, |
| 532 | <tt>.git/HEAD</tt> pointer and index file are left intact).</p> |
| 533 | <p>You may have local modifications in the working tree files. In |
| 534 | other words, <tt>git-diff</tt> is allowed to report changes. |
| 535 | However, the merge uses your working tree as the working area, |
| 536 | and in order to prevent the merge operation from losing such |
| 537 | changes, it makes sure that they do not interfere with the |
| 538 | merge. Those complex tables in read-tree documentation define |
| 539 | what it means for a path to "interfere with the merge". And if |
| 540 | your local modifications interfere with the merge, again, it |
| 541 | stops before touching anything.</p> |
| 542 | <p>So in the above two "failed merge" case, you do not have to |
Junio C Hamano | 51c2ab0 | 2006-07-09 20:38:54 | [diff] [blame] | 543 | worry about loss of data --- you simply were not ready to do |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 544 | a merge, so no merge happened at all. You may want to finish |
| 545 | whatever you were in the middle of doing, and retry the same |
| 546 | pull after you are done and ready.</p> |
| 547 | <p>When things cleanly merge, these things happen:</p> |
| 548 | <ol> |
| 549 | <li> |
| 550 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 551 | The results are updated both in the index file and in your |
| 552 | working tree; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 553 | </p> |
| 554 | </li> |
| 555 | <li> |
| 556 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 557 | Index file is written out as a tree; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 558 | </p> |
| 559 | </li> |
| 560 | <li> |
| 561 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 562 | The tree gets committed; and |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 563 | </p> |
| 564 | </li> |
| 565 | <li> |
| 566 | <p> |
Junio C Hamano | 092f5f0 | 2007-08-02 07:23:38 | [diff] [blame] | 567 | The <tt>HEAD</tt> pointer gets advanced. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 568 | </p> |
| 569 | </li> |
| 570 | </ol> |
| 571 | <p>Because of 2., we require that the original state of the index |
| 572 | file to match exactly the current <tt>HEAD</tt> commit; otherwise we |
| 573 | will write out your local changes already registered in your |
| 574 | index file along with the merge result, which is not good. |
| 575 | Because 1. involves only the paths different between your |
| 576 | branch and the remote branch you are pulling from during the |
| 577 | merge (which is typically a fraction of the whole tree), you can |
| 578 | have local modifications in your working tree as long as they do |
| 579 | not overlap with what the merge updates.</p> |
| 580 | <p>When there are conflicts, these things happen:</p> |
| 581 | <ol> |
| 582 | <li> |
| 583 | <p> |
| 584 | <tt>HEAD</tt> stays the same. |
| 585 | </p> |
| 586 | </li> |
| 587 | <li> |
| 588 | <p> |
| 589 | Cleanly merged paths are updated both in the index file and |
| 590 | in your working tree. |
| 591 | </p> |
| 592 | </li> |
| 593 | <li> |
| 594 | <p> |
| 595 | For conflicting paths, the index file records up to three |
| 596 | versions; stage1 stores the version from the common ancestor, |
| 597 | stage2 from <tt>HEAD</tt>, and stage3 from the remote branch (you |
| 598 | can inspect the stages with <tt>git-ls-files -u</tt>). The working |
| 599 | tree files have the result of "merge" program; i.e. 3-way |
| 600 | merge result with familiar conflict markers <tt><<< === >>></tt>. |
| 601 | </p> |
| 602 | </li> |
| 603 | <li> |
| 604 | <p> |
| 605 | No other changes are done. In particular, the local |
| 606 | modifications you had before you started merge will stay the |
| 607 | same and the index entries for them stay as they were, |
| 608 | i.e. matching <tt>HEAD</tt>. |
| 609 | </p> |
| 610 | </li> |
| 611 | </ol> |
| 612 | <p>After seeing a conflict, you can do two things:</p> |
| 613 | <ul> |
| 614 | <li> |
| 615 | <p> |
| 616 | Decide not to merge. The only clean-up you need are to reset |
| 617 | the index file to the <tt>HEAD</tt> commit to reverse 2. and to clean |
| 618 | up working tree changes made by 2. and 3.; <tt>git-reset</tt> can |
| 619 | be used for this. |
| 620 | </p> |
| 621 | </li> |
| 622 | <li> |
| 623 | <p> |
| 624 | Resolve the conflicts. <tt>git-diff</tt> would report only the |
| 625 | conflicting paths because of the above 2. and 3.. Edit the |
Junio C Hamano | 89d4e0f | 2007-02-18 00:34:59 | [diff] [blame] | 626 | working tree files into a desirable shape, <tt>git-add</tt> or <tt>git-rm</tt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 627 | them, to make the index file contain what the merge result |
| 628 | should be, and run <tt>git-commit</tt> to commit the result. |
| 629 | </p> |
| 630 | </li> |
| 631 | </ul> |
| 632 | </div> |
| 633 | <h2>SEE ALSO</h2> |
| 634 | <div class="sectionbody"> |
| 635 | <p><a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>, <a href="git-pull.html">git-pull(1)</a></p> |
| 636 | </div> |
| 637 | <h2>Author</h2> |
| 638 | <div class="sectionbody"> |
| 639 | <p>Written by Junio C Hamano <junkio@cox.net></p> |
| 640 | </div> |
| 641 | <h2>Documentation</h2> |
| 642 | <div class="sectionbody"> |
| 643 | <p>Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.</p> |
| 644 | </div> |
| 645 | <h2>GIT</h2> |
| 646 | <div class="sectionbody"> |
| 647 | <p>Part of the <a href="git.html">git(7)</a> suite</p> |
| 648 | </div> |
| 649 | <div id="footer"> |
| 650 | <div id="footer-text"> |
Junio C Hamano | 1974bf2 | 2007-10-31 05:57:20 | [diff] [blame] | 651 | Last updated 31-Oct-2007 05:56:48 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 652 | </div> |
| 653 | </div> |
| 654 | </body> |
| 655 | </html> |