There are 4 files involved:
$LOCAL
The file on the branch where you are merging; untouched by the merge process when shown to you
$REMOTE
The file on the branch from where you are merging; untouched by the merge process when shown to you
$BASE
The common ancestor of $LOCAL and $REMOTE, ie. the point where the two branches started diverting the considered file; untouched by the merge process when shown to you
$MERGED
The partially merged file, with conflicts; this is the only file touched by the merge process and, actually, never shown to you in meld
The $MERGED
file is the one that contains the <<<<<<
, >>>>>>
, =====
(and, maybe, ||||||
) markers (that delimit conflicts). This is the file that you edit manually to correct conflicts.
The manual conflicts editing and the visual conflicts editing are done on different files and presented different informations.
When using the mergetool (assume meld
), the files that are seeing therein are: $LOCAL
, $BASE
, $REMOTE
. Note that you don't see the $MERGED
file, although this is passed as a hidden parameter to meld
to write the result of the edit there.
In other words, in meld
, you are editing the file in the middle, the $BASE
file, and you pick all the changes from left or from the right manually. It is a clean file, not touched by the merge process. The only glitch is that, when you save, you do not save into the $BASE
file, but in the fourth hidden parameter of meld
, that is the $MERGED
file (that you do not even see). The $BASE
file does not contain any conflicts or partial successful merges because it is not the $MERGED
file.
In the visual editing, when presenting to you the $BASE
file (instead of the $MERGED
file) git
basically discards all its attempts to do the merging (those attempts are visible, if you want, in the $MERGED file) and lets you to completely do the merging from scratch.
The bottom line is that in manual and visual merging conflicts you are not looking at the same files, but the final result is written in the same file (that is the $MERGED
file).
The manual correction of the conflicts is done on $MERGED
because git
has no mean to present you three files, so it squashes the information from the three files ($LOCAL
, $BASE
, $REMOTE
) in that $MERGED
file.
But the visual tools have the means to show you three files: they show you the $LOCAL
, $BASE
, $REMOTE
files. You are picking changes from the $LOCAL
and $REMOTE
files and you are bringing those into the $BASE
file, completely re-building and even overwriting the failed attempt of merging that is the $MERGED
file.
merge.conflictstyle
configuration option set todiff3
instead of the defaultmerge
. – Igloo