git cherry-pick

Apply specific commits from one branch to another, selectively incorporating changes without merging everything.

You've fixed a critical bug on your feature branch, and you need that same fix in the release branch immediately, but you can't merge the entire feature branch because it contains unfinished work. git cherry-pick lets you apply specific commits to your current branch, copying changes without bringing the whole history along.

Running git cherry-pick abc123 while on the release branch applies the commit abc123 to your current branch. Git creates a new commit with the same changes and message, but with a different SHA because its parent commit is different. This is perfect for backporting bug fixes, porting features between branches, or recovering specific commits from abandoned branches.

You can cherry-pick multiple commits at once with git cherry-pick abc123 def456 ghi789, or a range with git cherry-pick abc123..ghi789. If conflicts occur—the code changed differently in both places—Git stops and asks you to resolve them, just like with merge or rebase. After resolving and staging files, git cherry-pick --continue finishes the operation.

In pull request workflows, cherry-pick helps when you realize a commit belongs on a different branch. Maybe you committed a fix to the wrong branch, or you need to create a hotfix from work that's part of a larger feature. Cherry-pick lets you grab exactly what you need without complex branch manipulation.

Understanding cherry-pick means understanding that it duplicates commits across branches. The original commit stays where it is, and a new commit with the same changes appears on your current branch. This can create a messier history than merging, so use it selectively when you truly need specific commits rather than whole branches.