Progress:
TIER 3 · MODULE 22· Expert

git cherry

Used to detect what you've already cherry-picked upstream.

🎯 What & why

git cherry tells you which commits on your branch are NOT yet in upstream, marking with '+' the ones still missing and '-' the ones whose patch-id is already there (typically because they were cherry-picked or rebased upstream).

🧠 Mental model

It's a patch-id comparison: same diff content => same commit, even with different SHAs. Pairs naturally with git patch-id under the hood.

🛠️ Synopsis

git cherry [-v] [--abbrev[=<n>]] [<upstream> [<head> [<limit>]]]

🎚️ Switches & options

FlagWhat it does
<upstream>Branch you're comparing against; default is the upstream of HEAD.
<head>Branch whose commits to classify; defaults to HEAD.
<limit>Stop walking before this commit (exclusive).
-vVerbose: also print the commit subject after each marker.
--abbrev[=<n>]Show abbreviated SHAs of length <n> instead of full 40 chars.

💡 Use cases

🧪 Examples

Default check vs upstream
git cherry -v
Compare topic vs main
git cherry -v main topic
Short SHAs in output
git cherry -v --abbrev=8 main
Limit how far back to walk
git cherry main topic v1.2.0

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

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