1

TL/DR

How can we make git merge prefer their deletion over our move ?

I tried

git merge origin/develop --strategy-option theirs

but this results in (trimmed)

$ git merge origin/develop --strategy-option theirs
...
CONFLICT (rename/delete): olddir1/src/xxx.cls renamed to newroot/src/xxx.cls in HEAD, but deleted in origin/develop.
...
CONFLICT (rename/delete): olddir2/src/yyy.w renamed to newroot/src/yyy.w in HEAD, but deleted in origin/develop.
...
Automatic merge failed; fix conflicts and then commit the result.

Is there an option to automatically resolve this to their deletion ?

I looked at Resolve Git merge conflicts in favor of their changes during a pull, but the answers there don't seem to apply to this particular case.

Background info

We are doing some major re-ordering of directories in our git repo.

Our development is done in a develop branch.

The re-ordering is done in a branch develop23, this will eventually become the new develop branch, but at the moment we are just testing the effect the reordering has on our application and on the EDI.

The only changes done in develop23 are lots of git mv's and a couple of git rm's. All code changes are still done in the develop branch.

At first, it seemed that updates to develop could be merged effortlessly into develop23. Everything found its way to the new location, but now I'm seeing conflicts on rename/delete.

Can I automate resolving this to their deletion ?

carl verbiest
  • 1,113
  • 1
  • 15
  • 30
  • I don't think there's a way to automate this. – j6t Jul 10 '23 at 11:24
  • "Can I automate resolving this to their deletion" No. Maybe you could write your own merge engine but it's probably not worth the effort. Just resolve manually. – matt Jul 10 '23 at 12:27
  • 1
    PS you are using "TLDR" incorrectly. – matt Jul 10 '23 at 12:29
  • @matt I tried to formulate my question short before the TLDR, and provide extra information in the TLDR. Isn't that how it's supposed to be used ? – carl verbiest Jul 10 '23 at 12:49
  • No, you have it backwards. "TLDR" refers to the summary ("short") part. – matt Jul 10 '23 at 13:32
  • It would be extremely easy to select and copy the output into a text editor, use simple regex commands to reduce this to `git rm 'olddir1/src/xxx.cls'; git rm 'olddir2/src/yyy.w';` etc., then just paste that into the Terminal and perform it. – matt Jul 10 '23 at 13:36

0 Answers0