0

When merging my branch, there are lots of those Modify/Delete conflicts. Too many to resolve manually.

When I do the

yes d | git mergetool

as described here: How do I fix a merge conflict due to removal of a file in a branch?, I can delete every file.

But I want to use whatever {remote} has, not just blindly delete. So if {remote} deleted the file, delete it. But if {local} deleted it and {remote} modified it, restore it.

How do I do this?

Thomas B.
  • 691
  • 4
  • 15
  • There's no trivial off-the-shelf solution for this that I know of (doesn't mean there isn't one), but it's easy to code up using `git status` or `git ls-files --stage`. You will have to write some shell script. Note that other than for renamed files (which are problematic) you're just looking for files that exist at stages 1 and 3 with different hash IDs, and do not exist at stage 2. Collect the names of such files and use `git checkout` or `git restore` to extract the `--theirs` version, then `git add` the result. – torek Apr 14 '22 at 10:55
  • This here did the trick for me: https://stackoverflow.com/a/46591569/7925800 – Thomas B. Apr 19 '22 at 07:16
  • That method does *more* than you asked for, so be very sure that the merge result you got is what you really wanted. – torek Apr 19 '22 at 13:54

0 Answers0