Play video

What is Git Cherry Pick?

At a high level, cherry picking means choosing a commit from one branch, and applying it to another. To be more exact, cherry pick allows you to apply the changes introduced by one (or more) existing commits onto another branch. Cherry pick is similar to Git merge and rebase - but rather taking an entire branch worth of commits, as you’d do with merge or rebase, cherry pick allows you to pick out only the ones you want.

Git Cherry Pick Cheatsheet

Cherry picking single commits

Get the unique identifier of the commit you want to pick

git log <branch-name> --oneline

Use cherry-pick to grab that commit by specifying it’s identifier

git cherry-pick <commit-hash>

Cherry picking multiple commits

Want to pick more than one commit? Cherry-pick can do that too:

Get the unique identifiers of the commits you want to pick

git log <branch-name> --oneline

Use cherry-pick to grab those commits by specifying it’s identifier

git cherry-pick <commit-1-hash> <commit-1-hash>

You can specify any number of commits you’d like; however, if you’re starting to pick a lot of commits, ask yourself if git merge, or git rebase are better tools.

Git also provides other ways to cherry-pick multiple commits.

Fix Cherry-Pick Merge Conflicts

Cherry-pick applies the changes introduced by the cherry-picked commit onto the current branch. If changes introduced by the picked commit conflict with changes to those files on the current branch, you will see a merge conflict.

To learn how to fix cherry-pick merge conflicts, check out the dedicated article I have on the subject.