Can we cherry-pick commits from two different branches into a third branch? For suppose I have two branches(develop and master). I created two branches A and B from develop and merged them into the develop branch.
I want to cherry-pick the changes I merged into develop branch to the master branch.
Can we do that? If so, how?
you simply have to checkout master
git checkout master
and then for each commit you want to cherry-pick from develop
(or from a
or from b
)
git cherry-pick -x <SHA of commit>
or if you want you can use a range where A
is the oldest to grab and B
is newest and want A
, B
, and everything in between: git cherry-pick -x A..B
that said as others have mentioned it might make more sense to simply merge develop
into master
unless there are other items on develop
that can't be merged yet. If you can't things do get more complicated. In that case I would consider rebasing A
and B
on top of master first using rebase --onto
you'll need some more syntax you can find on the web for that, merging them into master, and then merging master into develop to unify things. but if you want to cherry pick, go ahead.