git - Easiest way to "cherry-pick a merge" -


i know title little woolly - hence quotes!

say have branch, b_feature branched , merged main development branch b_master. there exists branch, b_release, wish add these changes (as point release). b_master , b_release have been diverged , never merged again.

---------bm----k1-----mm-----> b_master (k1 isn't included in b_release)  \        \          /   \        c1--c2--c3  (b_feature)    \     \----br---------mr-----> b_release           \        /             ca-cb-cc 

i know can cherry-pick whole thing single diff git cherry-pick -m mm, giving

     ----br--squashed----> b_release 

where squashed commit containing changes of feature, message of merge mm.

but if want retain change history , individual commit messages? can manually cherry-pick approximate workflow:

git checkout b_release git checkout -b b_release_feature git cherry-pick c1^..c3 git checkout b_release git merge b_release_feature git commit --amend --reedit-message=mm git branch -d b_release_feature 

but seems clunky workaround more elegant solution don't know!

rebase --onto b_release bm mm doesn't seem produce result looking for.

any better way it?

i think rebase more proper tool cherry-pick here, although difference minor. here how have done it. first attach b_release_feature branch source branch , rebase onto target branch.

git checkout -b b_release_feature c3 git rebase --onto b_release c1^ b_release_feature git checkout b_release git merge b_release_feature git commit --amend --reedit-message=mm git branch -d b_release_feature 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -