All commands

git cherry-pick

intermediate

Re-apply one specific commit onto your current branch.

What it does

git cherry-pick takes the changes introduced by any commit and replays them as a NEW commit on your current branch. It's your survival tool for 'get that one fix over here' across branches — without merging or rebasing whole histories.

9a2f1c0init project4b7c2a5main: basec1d8e2ffix: hotfix #42hotfixe5f6a7bmain: ship v10a9b8c7fix: hotfix #42'releaseHEAD

The fix commit is duplicated onto release with the identical diff but a new hash

Watch it — press play

A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.

1 / 2

Step 1

One fix, other branch too

A hotfix landed on main, but the release branch needs it right now — without merging all of main.

git cherry-pick c1d8e2f
9a2f1c0init project4b7c2a5basec1d8e2ffix: hotfix #42hotfixe5f6a7brelease v1releaseHEAD

The fix commit — about to travel

Under the hood

1

A narrowed three-way merge

Cherry-pick diffs the picked commit against its own parent, then three-way-merges that diff onto your current HEAD. The result is a new commit with fresh hash and a fresh parent — but identical content change.

main — A — B
picked commit: X (on feature)
result: A — B — X'   X' has same diff, new identity
2

Cherry-picking a range

`git cherry-pick A..B` replays every commit in that range, in order — a poor-man's selective rebase. Useful when a branch has exactly the fixes you want and nothing else.

3

Conflicts behave like merge conflicts

If 'your' current branch already changed the same lines, cherry-pick stops and asks you to resolve — markers in the file, then git cherry-pick --continue (or --abort).

Aliases the pros type

Memorize the git cherry-pick concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:

git config --global alias.st # → git cherry-pick
AliasWhy people use it
g cp

The classic rescue alias.

g cp -x

Keep provenance — traces back to the original fix.

Command anatomy

git cherry-pick <commit>
-n

Apply the changes but don't commit — merge a few picks first.

--continue / --abort

Finish or bail out of a conflicted pick.

-x

Add '(cherry picked from commit …)' to the message as provenance.

When to reach for it

A hotfix commit landed on main but the release branch needs it right now.

You committed to the wrong branch: cherry-pick it out, then reset the wrong branch.

Selectively assembling a release from several feature branches.

Pro tip

Committed to the wrong branch? `git cherry-pick <hash>` onto the right branch, then `git reset --hard HEAD~1` on the wrong one. That two-step is one of the most common recovery dances in a working day.

Go deeper with