Let's say I need to move several feature commits to the release branch. Should I move them from their immediate commits, not merge commits? An example of what I mean is in the image
I want to move the necessary commits to the master branch. There is no need to use merge request.
git cherry-pick
doesn't move commits from a branch to another, but rather creates new commits with the same modifications introduced by the given commits.
Given one or more existing commits, apply the change each one introduces, recording a new commit for each.
In your case, if you want to introduce on a branch the changes made on another branch, and assuming that your listed commits are called A
, B
, C
, D
, E
, F
with A
and C
as your merge commits, you could run:
# making sure to be on the branch you want to bring the changes into
git checkout <my_branch>
# picking the changes made by commits B, D, and E (creating 3 new commits on my_branch)
git cherry-pick B D E