Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use `git mergetool` with `git am` or `git apply` or `patch`

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.

like image 485
Jérôme Pouiller Avatar asked Sep 28 '18 13:09

Jérôme Pouiller


People also ask

What is git apply patch?

Applying a PatchIf the user wants to check these changes are correct or not, so a different branch is created from the master and applied the patch to check the changes. This is how the patch is applied in the new branch. Applying is done by git apply 0001-Add-description. patch where “0001-Add-description.

What is Mergetool in git?

DESCRIPTION. Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).

How do I apply a conflict patch?

If you are frequently running into the same conflict set when applying patches, rebasing or merging then you can use git rerere (reuse recorded resolution) function. This allows you to pre-define how conflicts should be resolved based on how you resolved them in the past.

How do I resolve merge conflict in Mergetool?

We can manually resolve the merge conflict by editing the content in the bottom pane, and then saving the file using :wqa (Write and Quit all files). Once the conflict resolution is successful, the merged file will be staged for commit. git commit -m 'Merged from multiple branches' .


1 Answers

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

  • doing a git am --3way
  • doing a regular git am, but with the config am.threeWay set to true.

The issue remains for a regular patch command.

like image 102
VonC Avatar answered Sep 30 '22 05:09

VonC