2

I have a repo like this (numbers are sequence of commits):

 1 -- 2 -- 5 [master]
       \
        3 -- 4  [feature]

In 1 I have files tool.txt and code.txt. In 3, both files were modified, but code.txt is a totally different thing from the old code.txt, it is in fact a new file.

In 4, code.txt is renamed alternative_code.txt.

I would like to merge the changes of feature into master, but alternate_code.txt should not replace code.txt in the merge, but be added as a new file. If I do a regular merge, the alternate code will replace the master's code.

In reality, I have a certain number of files that were handled like code.txt (replaced and then renamed).

Is there a practical way to merge the branch into master, without "backtracking" the rename and add the renamed files as new files, instead of trying to merge them?

If the file was not renamed, I want to do a regular merge.

Is this possible (e.g. by using a specific merge policy)?

EDIT

To clarify, after the merge master should have 3 files:

  • tool.txt, merged from master and feature
  • code.txt, the file that was in 5
  • alternate_code.txt, the file that was in 4

0 Answers0