Progress:
TIER 1 · MODULE 24· Basics

git cherry-pick

Take a commit from another branch and replay it on this one.

🎯 What & why

Apply a single commit (or a sequence) from one branch onto another. The picked commit gets a new SHA but the same change.

🧠 Mental model

Cherry-pick computes the diff of <commit> vs its parent and applies it on top of HEAD. If conflicts hit, resolve and git cherry-pick --continue. Multiple SHAs can be passed.

🛠️ Synopsis

git cherry-pick [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff]
                [-S[<keyid>]] <commit>...
git cherry-pick (--continue | --skip | --abort | --quit)

🎚️ Switches & options

FlagWhat it does
-n, --no-commitApply the changes, stage them, but don't commit.
-xAdd a 'cherry picked from <sha>' line to the commit message.
-m <n>When picking a merge commit, choose mainline parent.
--ffFast-forward if possible.
--abort/--continue/--skipSame flow as merge/rebase conflicts.

💡 Use cases

🧪 Examples

Pick one commit onto current branch.
$ git cherry-pick a1b2c3d
Pick a range (exclusive of a).
$ git cherry-pick a..b
Pick with provenance trailer.
$ git cherry-pick -x abc1234

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.