0

I was wondering how can I merge (or other action like cherry pick, rebase, ...) automatically (without manual resolving) two commits with a rename of a same file. More precisely, I've two commits which do:

  • A.txt -> B.txt
  • A.txt -> folder/A.txt

And I want automatically:

  • A.txt -> folder/B.txt

Is it possible?

I searched solutions but I didn't find automatic ones. I tried merge, rebase, cherry pick. I tried arguments of merge strategies but it didn't work also.

1 Answers1

2

No, unfortunately, it is not possible automatically. You change the name of a file in two incompatible ways. Git cannot possibly know which name to pick (and it definitely isn't going to "make up" a new name that it hasn't seen before).

You must manually resolve this, just like you have to manually resolve 2 changes to the same line.

Why? Let's increase the "difficulty":

  1. folder/A.txt => new/B.txt
  2. folder/A.txt => folder/old/C.txt

What would the result be? new/C.txt? folder/new/B.txt? folder/new/C.txt? folder/B.txt?

knittl
  • 246,190
  • 53
  • 318
  • 364