Frequently Asked Question

What is git cherry-pick and when should I use it?

git cherry-pick <commit> takes a single existing commit and applies its changes on top of the current branch, creating a new commit with the same message and diff but a different hash and parent. It is the right tool when one specific change, a bug fix, a small feature, needs to land on more than one branch (say, both main and a stable release branch) without merging the rest of the divergent history. You can cherry-pick a range with git cherry-pick A..B, and Git will replay each commit in turn.

Two warnings. First, cherry-picking duplicates commits: the same logical change now lives at two different hashes in your history. If you later merge the source branch into the target, Git may or may not notice and may produce conflicts on the duplicated lines. Second, conflicts during cherry-pick are resolved exactly like merge conflicts: fix the files, git add, and git cherry-pick --continue. Use cherry-pick sparingly; if you find yourself cherry-picking many commits, you probably want a proper merge or rebase instead.

Further reading and video