From 70a3f89733a4cd21631690ba980598fea2249067 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 31 Aug 2008 20:36:32 -0700 Subject: git-merge documentation: describe how conflict is presented We took it granted that everybody knows how to read the RCS merge style conflicts, and did not give illustrations in the documentation. Now we are introducing an alternative output style, it is time to document this. The lack of illustration has been bugging me for a long time. Signed-off-by: Junio C Hamano --- Documentation/git-merge.txt | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'Documentation/git-merge.txt') diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 17a15acb07..8065d17781 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -119,6 +119,71 @@ When there are conflicts, these things happen: same and the index entries for them stay as they were, i.e. matching `HEAD`. +HOW CONFLICTS ARE PRESENTED +--------------------------- + +During a merge, the working tree files are updated to reflect the result +of the merge. Among the changes made to the common ancestor's version, +non-overlapping ones (that is, you changed an area of the file while the +other side left that area intact, or vice versa) are incorporated in the +final result verbatim. When both sides made changes to the same area, +however, git cannot randomly pick one side over the other, and asks you to +resolve it by leaving what both sides did to that area. + +By default, git uses the same style as that is used by "merge" program +from the RCS suite to present such a conflicted hunk, like this: + +------------ +Here are lines that are either unchanged from the common +ancestor, or cleanly resolved because only one side changed. +<<<<<<< yours:sample.txt +Conflict resolution is hard; +let's go shopping. +======= +Git makes conflict resolution easy. +>>>>>>> theirs:sample.txt +And here is another line that is cleanly resolved or unmodified. +------------ + +The area a pair of conflicting changes happened is marked with markers +"<<<<<<", "=======", and ">>>>>>>". The part before the "=======" is +typically your side, and the part after it is typically their side. + +The default format does not show what the original said in the conflicted +area. You cannot tell how many lines are deleted and replaced with the +Barbie's remark by your side. The only thing you can tell is that your +side wants to say it is hard and you'd prefer to go shopping, while the +other side wants to claim it is easy. + +An alternative style can be used by setting the "merge.conflictstyle" +configuration variable to "diff3". In "diff3" style, the above conflict +may look like this: + +------------ +Here are lines that are either unchanged from the common +ancestor, or cleanly resolved because only one side changed. +<<<<<<< yours:sample.txt +Conflict resolution is hard; +let's go shopping. +||||||| +Conflict resolution is hard. +======= +Git makes conflict resolution easy. +>>>>>>> theirs:sample.txt +And here is another line that is cleanly resolved or unmodified. +------------ + +In addition to the "<<<<<<", "=======", and ">>>>>>>" markers, it uses +another "|||||||" marker that is followed by the original text. You can +tell that the original just stated a fact, and your side simply gave in to +that statement and gave up, while the other side tried to have a more +positive attitude. You can sometimes come up with a better resolution by +viewing the original. + + +HOW TO RESOLVE CONFLICTS +------------------------ + After seeing a conflict, you can do two things: * Decide not to merge. The only clean-up you need are to reset -- cgit v1.2.3 From 3407a7a9e67b165902be85b0807e9ea789b3c67d Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Thu, 4 Sep 2008 23:48:48 +0200 Subject: Fix AsciiDoc errors in merge documentation In the section on conflict markers, the "<<<<<<<" sequence is compiled by AsciiDoc into invalid XML. A way to resolve this is by inserting something between the last two characters in that sequence (i.e. between '<' and '"'). This patch encloses the conflict markers in backticks, which renders them in a monospace font (in the HTML version; the manual page is unaffected), and with the pleasant side-effect that it also fixes the AsciiDoc compile problem. Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- Documentation/git-merge.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Documentation/git-merge.txt') diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 8065d17781..18750467d8 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -146,8 +146,8 @@ And here is another line that is cleanly resolved or unmodified. ------------ The area a pair of conflicting changes happened is marked with markers -"<<<<<<", "=======", and ">>>>>>>". The part before the "=======" is -typically your side, and the part after it is typically their side. +"`<<<<<<<`", "`=======`", and "`>>>>>>>`". The part before the "`=======`" +is typically your side, and the part after it is typically their side. The default format does not show what the original said in the conflicted area. You cannot tell how many lines are deleted and replaced with the @@ -173,8 +173,8 @@ Git makes conflict resolution easy. And here is another line that is cleanly resolved or unmodified. ------------ -In addition to the "<<<<<<", "=======", and ">>>>>>>" markers, it uses -another "|||||||" marker that is followed by the original text. You can +In addition to the "`<<<<<<<`", "`=======`", and "`>>>>>>>`" markers, it uses +another "`|||||||`" marker that is followed by the original text. You can tell that the original just stated a fact, and your side simply gave in to that statement and gave up, while the other side tried to have a more positive attitude. You can sometimes come up with a better resolution by -- cgit v1.2.3