I have two branches, for example master
and old-release
. In master
I have a commit C
that I want to backport, but I also introduced required changes (like a refactoring) in a previous commit R
that are needed to cherry-pick C
into old-release
without merge-conflict. How can I get the list of commits that are needed to cherry-pick C
from master
to old-release
(recursively if R
itself has dependent commits not in the target branch)?
* C (master)
* unrelated-3
* unrelated-2
* R
* unrelated-1
| * other fix (old-release)
| /
* unrelated-0
* ...
Said otherwise, give a commit C
and a target branch old-release
, I want the list of commits that, if cherry picked in order would allow to cherry-pick C
into old-release
without any merge conflict.
If we name the common ancestor A
, I assume that such command or external tool would use the same mechanism than git blame
look at all the line modified by C
, and if the original line was not present in A
, then add that commit to the list of commit to cherry-pick, then repeat for all those other commits.