Git Cherry Picking
Posted on August 28, 2020 in Git by Matt Jennings
Definition
Cherry picking in Git means to choose a commit from one branch and apply it onto another.
Example
- I have two branches, master and exercize2.
- Switch to branch master and create a new file with text:
echo 'Master of the Universe!' > master.txt
- Commit that change on master and switch to exercise2 branch.
- While on the exercise2 branch, cherry pick that specific master branch commit SHA1 by using something like below which will create a new commit:
git cherry-pick 5a07a80
- Or to NOT create a new commit while cherry picking:
git cherry-pick 5a07a80 -n