When I use meld as git mergetool
for solving conflict while merging, meld shows me the differences between local/output and remote/output files (in blue or green) that git automatically solves, and not only the actual conflicts (that are red highlighted). And when I click on the down arrow, it goes to the next (blue/green) difference, and not to the next conflict (red). In this topic, a picture illustrates this.
How could I
Add the following to your .gitconfig
:
[mergetool "meld"]
cmd = meld --auto-merge "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"
This is the same command Git runs by default with --auto-merge
specified so that Meld automatically resolves what it can.
In addition to meld-specific parameters, you now have new Git options:
With Git 2.31 (Q1 2021), "git mergetool
"(man) feeds three versions (base, local and remote) of a conflicted path unmodified.
The command learned to optionally prepare these files with unconflicted parts already resolved.
See commit 9d9cf23, commit de8dafb, commit 98ea309 (09 Feb 2021) by Seth House (whiteinge
).
(Merged by Junio C Hamano -- gitster
-- in commit 78a26cb, 17 Feb 2021)
mergetool
: addhideResolved
configurationOriginal-implementation-by: Felipe Contreras
Signed-off-by: Seth House
The purpose of a mergetool is to help the user resolve any conflicts that Git cannot automatically resolve.
If there is a conflict that must be resolved manually Git will write a file named MERGED which contains everything Git was able to resolve by itself and also everything that it was not able to resolve wrapped in conflict markers.One way to think of
MERGED
is as a two- or three-way diff.
If each "side" of the conflict markers is separately extracted an external tool can represent those conflicts as a side-by-side diff.However many mergetools instead diff
LOCAL
andREMOTE
both of which contain versions of the file from before the merge.
Since the conflicts Git resolved automatically are not present it forces the user to manually re-resolve those conflicts.
Some mergetools also showMERGED
but often only for reference and not as the focal point to resolve the conflicts.This adds a
mergetool.hideResolved
flag that will overwriteLOCAL
andREMOTE
with each corresponding "side" of a conflicted file and thus hide all conflicts that Git was able to resolve itself.
Overwriting these files will immediately benefit any mergetool that uses them without requiring any changes to the tool.No adverse effects were noted in a small survey of popular mergetools so this behavior defaults to
true
.
However it can be globally disabled by settingmergetool.hideResolved
tofalse
.
See "Mergetools: Stop doing three-way merges!"
git config
now includes in its man page:
mergetool.hideResolved
During a merge Git will automatically resolve as many conflicts as possible and write the 'MERGED' file containing conflict markers around any conflicts that it cannot resolve; 'LOCAL' and 'REMOTE' normally represent the versions of the file from before Git's conflict resolution.
This flag causes 'LOCAL' and 'REMOTE' to be overwriten so that only the unresolved conflicts are presented to the merge tool.
Can be configured per-tool via the
mergetool.<tool>.hideResolved
configuration variable. Defaults totrue
.
In the OP's case:
git config --global mergetool.meld.hideResolved true
This is described in:
mergetool
: add per-tool support and overrides for the hideResolved flagHelped-by: Johannes Sixt
Helped-by: Junio C Hamano
Signed-off-by: Seth House
Add a per-tool override flag so that users may enable the flag for one tool and disable it for another by setting
mergetool.<tool>.hideResolved
tofalse
.In addition, the author or maintainer of a mergetool may optionally override the default
hideResolved
value for that mergetool.
If themergetools/<tool>
shell script contains ahide_resolved_enabled
function it will be called when the mergetool is invoked and the return value will be used as the default for thehideResolved
flag.hide_resolved_enabled () { return 1 }
Disabling may be desirable if the mergetool wants or needs access to the original, unmodified 'LOCAL' and 'REMOTE' versions of the conflicted file.
For example:
- A tool may use a custom conflict resolution algorithm and prefer to ignore the results of Git's conflict resolution.
- A tool may want to visually compare/constrast the version of the file from before the merge (saved to 'LOCAL', 'REMOTE', and 'BASE') with Git's conflict resolution results (saved to 'MERGED').
git config
now includes in its man page:
mergetool.<tool>.hideResolved
Allows the user to override the global
mergetool.hideResolved
value for a specific tool.
In meld, you can click Changes > Merge All, which will merge most changes except for the conflicts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With