When to Use Cherry-Picking
If you’re working on the master branch and identify a single commit in a feature branch (for example, the Sarah branch) that introduces a vital fix or enhancement, cherry-picking enables you to import that specific change without merging the entirety of the feature branch.Before proceeding with cherry-picking, ensure that your target branch is up-to-date and that you understand how the changes from the commit will integrate with your current code base.
How to Cherry-Pick a Commit
To cherry-pick a commit, you’ll use the commit’s unique hash value. In the scenario where you wish to apply the changes from a commit on the Sarah branch to your master branch, follow these steps:- Switch to your master branch.
- Execute the cherry-pick command with the hash of the desired commit.
aaba5:
Cherry-picking only transfers the changes from the specified commit. Other commits and modifications from the source branch remain separate.