What is git cherry-pick
In git, Cherry picking means to choose a commit from one branch and apply it onto another.
Basic Syntax: git cherry-pick <commit-hash>
Cherry picking will merge the specify commit to your current checkout branch.
When we need cherry pick
Suppose we have three branch – say master branch, feature branch and testing branch. We are working in a feature branch that is not ready for merging into master branch (for release and testing). But we want to push an update to master for releasing purpose (for major error or else). We don’t want to merge full feature branch to master.
In this type of situation- Git’s
cherry-pick is really useful.
the possible step will be as follows:
Step1: git checkout master
step2: git checkout -b quick-fix
step3: git cherry-pick <target-commit-hash>
That’s it. Now you can merge this branch to your testing branch for testing purpose. After testing we can release the update.
To learn more about cherry click here