git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/6] Documentation: tweak How Merge Works

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 11, 2010, 08:43 UTC
Message-ID
<20100111084355.GF23806@progeny.tock>
In-Reply-To
<20100111082123.GA23742@progeny.tock>

Change heading to TRUE MERGE. The whole manual page is about how merges work.

Start to explain what it means to merge two commits into a single tree.

Do not assume the commits named on the 'git merge' command line come from another repository. For simplicity, still assume they are branch heads for now, though.

Do not give start any list items with `code`; a toolchain bug makes the resulting nroff look wrong.

Recommend reset --merged for safely cancelling a failed merge.
Cc: Petr Baudis <pasky@suse.cz>
Cc: Junio C Hamano <gitster@pobox.com>
Cc: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Documentation/git-merge.txt |   56 +++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index ec9c6d3..7ae0f65 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -96,62 +96,56 @@ merge commit.
 
 This behavior can be suppressed with the `--no-ff` option.
 
-include::merge-strategies.txt[]
-
-
-If you tried a merge which resulted in complex conflicts and
-want to start over, you can recover with 'git-reset'.
-
-HOW MERGE WORKS
----------------
-
-A merge is always between the current `HEAD` and one or more
-commits (usually, branch head or tag).
+TRUE MERGE
+----------
 
 Except in a fast-forward merge (see above), the branches to be
 merged must be tied together by a merge commit that has both of them
 as its parents.
 The rest of this section describes this "True merge" case.
 
-The chosen merge strategy merges the two commits into a single
-new source tree.
 When things merge cleanly, this is what happens:
 
-1. The results are updated both in the index file and in your
-   working tree;
-2. Index file is written out as a tree;
+1. A version reconciling the changes from all branches to be
+   merged is written to the index file and your working tree;
+2. The index file is written out as a tree;
 3. The tree gets committed; and
 4. The `HEAD` pointer gets advanced.
 
 Because of 2., we require that the original state of the index
 file matches exactly the current `HEAD` commit; otherwise we
-will write out your local changes already registered in your
+would write out your local changes already registered in your
 index file along with the merge result, which is not good.
 Because 1. involves only those paths differing between your
-branch and the remote branch you are pulling from during the
-merge (which is typically a fraction of the whole tree), you can
-have local modifications in your working tree as long as they do
-not overlap with what the merge updates.
-
-When there are conflicts, the following happens:
+branch and the other branches (which is typically a fraction of
+the whole tree), you can have local modifications in your
+working tree as long as they do not overlap with what the merge
+updates.
 
-1. `HEAD` stays the same.
+When it is not obvious how to reconcile the changes, the following
+happens:
 
-2. Cleanly merged paths are updated both in the index file and
+1. The `HEAD` pointer stays the same.
+2. The `MERGE_HEAD` ref is set to point to the other branch head.
+3. Paths that merged cleanly are updated both in the index file and
    in your working tree.
-
-3. For conflicting paths, the index file records up to three
+4. For conflicting paths, the index file records up to three
    versions; stage1 stores the version from the common ancestor,
-   stage2 from `HEAD`, and stage3 from the remote branch (you
+   stage2 from `HEAD`, and stage3 from `MERGE_HEAD` (you
    can inspect the stages with `git ls-files -u`).  The working
    tree files contain the result of the "merge" program; i.e. 3-way
-   merge results with familiar conflict markers `<<< === >>>`.
-
-4. No other changes are done.  In particular, the local
+   merge results with familiar conflict markers `<<<` `===` `>>>`.
+5. No other changes are done.  In particular, the local
    modifications you had before you started merge will stay the
    same and the index entries for them stay as they were,
    i.e. matching `HEAD`.
 
+If you tried a merge which resulted in complex conflicts and
+want to start over, you can recover with `git reset --merged`.
+
+include::merge-strategies.txt[]
+
+
 HOW CONFLICTS ARE PRESENTED
 ---------------------------
 
-- 
1.6.6
Previous: Jonathan NiederNext: Thomas Rast
Message 26 of 46 in “Documentation/git-merge: reword references to "remote" and "pull"”
  1. 1/2 Documentation/git-merge: reword references to "remote" and "pull"Thomas Rast, Jan 7, 2010
  2. 2/2 Documentation: warn prominently against merging with dirty treesThomas Rast, Jan 7, 2010
  3. 3/2 Documentation/git-merge: format full commands in typewriter fontThomas Rast, Jan 7, 2010
  4. Jonathan NiederJan 7, 2010
  5. Junio C HamanoJan 7, 2010
  6. Junio C HamanoJan 7, 2010
  7. 0/4 Documentation style fixesThomas Rast, Jan 10, 2010
  8. 1/4 Documentation/git-merge: reword references to "remote" and "pull"Thomas Rast, Jan 10, 2010
  9. Jonathan NiederJan 10, 2010
  10. Thomas RastJan 10, 2010
  11. Documentation: merge: use MERGE_HEAD to refer to the remote branchJonathan Nieder, Jan 23, 2010
  12. 2/4 Documentation: warn prominently against merging with dirty treesThomas Rast, Jan 10, 2010
  13. Jonathan NiederJan 10, 2010
  14. Junio C HamanoJan 10, 2010
  15. Thomas RastJan 10, 2010
  16. Jonathan NiederJan 11, 2010
  17. Junio C HamanoJan 11, 2010
  18. Jonathan NiederJan 11, 2010
  19. 0/6 Re: Documentation: warn prominently against merging with dirty treesJonathan Nieder, Jan 11, 2010
  20. 1/6 Documentation: clarify one-line description for mergeJonathan Nieder, Jan 11, 2010
  21. 2/6 Documentation: merge: add an overviewJonathan Nieder, Jan 11, 2010
  22. Junio C HamanoJan 11, 2010
  23. 4/6 Documentation: emphasize when git merge terminates earlyJonathan Nieder, Jan 11, 2010
  24. Thomas RastJan 11, 2010
  25. 5/6 Documentation: merge: add a section about fast-forwardJonathan Nieder, Jan 11, 2010
  26. 6/6 Documentation: tweak How Merge WorksJonathan Nieder, Jan 11, 2010
  27. Thomas RastJan 11, 2010
  28. Petr BaudisJan 13, 2010
  29. Junio C HamanoJan 13, 2010
  30. 3/4 Documentation: format full commands in typewriter fontThomas Rast, Jan 10, 2010
  31. Jonathan NiederJan 10, 2010
  32. Thomas RastJan 10, 2010
  33. Thomas RastJan 10, 2010
  34. Junio C HamanoJan 10, 2010
  35. Thomas RastJan 10, 2010
  36. 1/2 More missed dashed 'git-cmd' formsThomas Rast, Jan 10, 2010
  37. 2/2 More missed `code snippets`Thomas Rast, Jan 10, 2010
  38. Documentation: show-files is now called git-ls-filesThomas Rast, Jan 10, 2010
  39. Junio C HamanoJan 18, 2010
  40. Thomas RastJan 19, 2010
  41. Jonathan NiederJan 19, 2010
  42. Junio C HamanoJan 10, 2010
  43. Jonathan NiederJan 10, 2010
  44. 1/2 Documentation: git gc packs refs by default nowJonathan Nieder, Jan 10, 2010
  45. 2/2 Documentation: tiny git config manual tweaksJonathan Nieder, Jan 10, 2010
  46. Thomas RastJan 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.