33.10 Git Cherry Pick

20240516

A cherry-pick allows the selective incorporation of commits from different branches (dev) into the current branch (main).

Use case: Dev to Main Cherry Pick

Change to the main branch:

git checkout main
git pull

Look for a commit to merge from the dev branch:

git log --pretty=oneline -n 20 dev

Merge that commit into the current branch:

git cherry-pick 44c425bb199c4e36496d8065521ad8c5e005f99a
git push

Use case: Pick from a pull request

$ git remote add simon <https://github.com/simonzhaoms/mlhub.git>
$ git remote -v
$ git checkout -b deletable
$ git fetch simon
$ git cherry-pick <commit-hash>
$ git checkout main
$ git merge deletable
$ git branch -v
$ git branch -D deletable
$ git push


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0