0

1) Branch firstBranch:

rename /frontends/myfrontend/utils/myfile.js to /frontends/myfrontend/utils/myfile2.js


2) Branch secondBranch

rename /frontends/myfrontend to /frontends/myfrontend2


Now I want to merge firstBranch into secondBranch, while keeping both renames applied (since one is over a parent directory, and the other over a child file).

Rename strategies (find-renames and rename-threshold) are dealing only on identifying changed content being renamed, but I think this is a different case. The content is the same, it is just that git does not allow me to solve the merge by applying both renames.

How should I deal with this? I know git does not understand about directories, nevertheless I think it is a real use case.

isherwood
  • 58,414
  • 16
  • 114
  • 157
lqbweb
  • 1,684
  • 3
  • 19
  • 33

1 Answers1

0

When you go to combine these, if Git detects all the renames from the merge-base commit to the tip commit of secondBranch and the (single) rename from merge-base to tip of firstBranch, you will get a rename/rename conflict.

The merge will stop, having done all the rest of the renames and combinations as appropriate. Your job is to finish things. There is only one thing to finish, at least from this particular conflict: you must choose the desired name for this file.

Write the desired file contents under the desired name—this may require using mv to rename the file in the work-tree, and/or editing the file if the contents are not what you want—and then use git add and git rm as needed / appropriate to update Git's index to store the possibly-updated file under the desired name. You have now resolved the rename/rename conflict.

Resolve any other conflicts as well, so that all conflicts are resolved, and Git's index contains the snapshot you would like as the merge result. Then run:

git merge --continue

to finish the merge.

torek
  • 448,244
  • 59
  • 642
  • 775