Cannot use `git mergetool` with `git am` or `git apply` or `patch`
Asked Answered
S

1

6

git mergetool is wonderful (in my case, I use kdiff3). However, it is not possible to use it to resolve conflicts from git am or git apply (or even with patch command). Indeed, mergetool need 3 files to work (base and both modified versions) while git am work with a modified version and a patch.

Do you know a way to use git mergetool for conflicts produced with git am?

I think it is necessary to guess the base file from modified version and patch. If you consider each chunk separately, it looks tricky, but not impossible.

Susurrous answered 28/9, 2018 at 13:3 Comment(1)
git mergetool should work if you've hit a three-way merge conflict. git am runs git apply --3way, which uses the index lines in git diff output to locate or reconstruct (when possible) the three objects. If you're finding patches that don't apply and have missing or wrong or inadequate index lines, there's nothing you can do here. Well, nothing three-way-ish: you can use git apply --reject and then hand-massage the rejected bits in an editor, the way we used to do all of this back in the bad old days...Nairn
R
3

As torek mentions, git mergetool will be involved if you are:

The issue remains for a regular patch command.

Razorbill answered 30/12, 2018 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.