0

I haven't use cherry-picking that much in the past, but I need to use it today. So far the commits are linear so I got no problem

But what happen in the following situation

enter image description here

I want to cherry pick all the commits from 1 to 7. But from commit 3 to 5 there was a merge (not fast forward)

I want to reproduce this in another branch (main for example)

Can I just cherry pick normally 1,2,3,4,5,6,7

or should I do 1,2,3,4,7,5,6?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • Please include what the final expected branch should look like. – Tim Biegeleisen May 31 '23 at 08:41
  • 1
    You say "1 to 7" but then continue to explain you want "1,2,3,4,5,6,7". Looking at your picture "1 to 7" is "1,2,3,7" – knittl May 31 '23 at 08:42
  • It should look the same but over another branch – KansaiRobot May 31 '23 at 08:42
  • @knittl at commit 3 I added two different commits 4 and 7 but divergent. commit 5 merged both – KansaiRobot May 31 '23 at 08:43
  • If you want to transplant the whole thing somewhere, a rebase may be more helpful. Other tips including "simplify (123476)", "use merge instead": https://stackoverflow.com/questions/9229301/git-cherry-pick-says-38c74d-is-a-merge-but-no-m-option-was-given – teapot418 May 31 '23 at 08:47
  • 3
    "I want to cherry pick all the commits from 1 to 7" That's called a _rebase_. And it will handle the merge commit for you. See https://stackoverflow.com/questions/4783599/rebasing-a-git-merge-commit – matt May 31 '23 at 08:48

0 Answers0