0

Imagine I have a master repository and some forked repositories. In a forked repo, some changes have been made quite a while ago. There is one commit in particular that I want to cherry-pick onto master. Imagine the original file (that the repo based off on) had this structure:

<div class="foo">
Text1
</div>
<div class="foo">
Text2
</div>

Meanwhile, master has evolved to this:

<div class="foo bar">
Text1
</div>
<div class="foo bar">
Text2
</div>

The relevant commit I want to cherry-pick however contains:

<div class="foo">
Text1
</div>
<div class="foo">
Changed Text2
</div>

When I run cherry-pick I get (expectedly) the message that there's a merge conflict. The merge conflict is tiny, only the two relevant lines:

<<<<<<< HEAD
<div class="foo bar">
Text2
=======
<div class="foo">
Changed Text2
>>>>>>> abababab Text

I want to make my life easier and use git mergetool to fix this issue. To my surprise, instead of showing only the relevant, tiny change, git mergetool however highlights every single instance where

<div class="foo">

was change to:

<div class="foo bar">

I.e., while the actual diff contained in the conflicted file is tiny, git mergetool is cluttered with hundreds of bogus diffs (well, it's not wrong, but it's also irrelevant) which make its use impossible. I'm using meld for diffing if that makes a difference. How do I get mergetool only to display the conflict that is contained in the actual conflicted file instead of trying to three-way merge with the common ancestor?

itecMemory
  • 301
  • 2
  • 8
  • `git mergetool` itself simply retrieves the three input files and feeds them to your chosen merge tool. So if meld is showing you this much detail, it's because meld thinks you should see it. There may be a way to configure meld to show you less detail, but that's a *meld* issue, not a *Git* issue: you may want to swap out all your question's tags. – torek Jul 14 '21 at 11:51
  • 1
    If you're on a current version of git (>=2.31), you can try the `hideresolved` option of mergetool, e.g. `git -c mergetool.meld.hideResolved=true mergetool`, this will use git's resolution for the non-conflicting changes. I'd suggest using it with care. See also https://stackoverflow.com/a/66297860/20270 – Hasturkun Jul 14 '21 at 11:55
  • @Hasturkun: ah, nice - I missed this update to mergetool (probably because I never use mergetool :-) ). – torek Jul 14 '21 at 22:16

0 Answers0