back to blog

WTF is `git cherry-pick`?

Written by Namit Jain·July 1, 2025·2 min read

Ever wished you could steal just one commit without dragging the entire messy branch with it?
Welcome to Git’s commit heist tool: git cherry-pick.


What actually happens?

Run:

git checkout main
git cherry-pick <commit-hash>

Git grabs the diff from <commit-hash> and replays it on main as a brand-new commit. Same content, fresh identity (new hash).


Why you need this

Hotfix emergencies: pluck that one bugfix without the noise. ✅ Selective feature moves: steal just the feature you want. ✅ History hacks: clean up messy branches by cherry-picking verified commits.

💡 Pro tip: If you need more than 3 commits, merging might be smarter. Don’t over-cherry-pick like a code raccoon.


Anatomy of the output

[main 5f8d3e2] Fix typo in README
 Author: teammate <teammate@example.com>
 Date:   Fri Jul 4 17:22:46 2025 +0530
  • 5f8d3e2 → brand new hash, no shady reuse.
  • Message & author? Still carried over for context clarity.

Conflict mode: activate

Conflicts are inevitable. When they hit:

  1. Fix markers (<<<<, ====, >>>>) in your favorite editor.

  2. git add <resolved-files>

  3. Continue the drama:

    git cherry-pick --continue

⚠️ WTF moment: Cherry-pick conflicts are like that one friend who says “I’ll be chill” and then flips the table.

Spooked? Reset with:

git cherry-pick --abort

Back to pre-cherry-pick bliss.


Pro tips

✅ Cherry-pick small, self-contained commits. Big ones? Big drama. ✅ Avoid merge commits unless you enjoy pain. ✅ Push right after you pick. Don’t ghost your teammates.


Quick scenario

  1. Team fixes a critical bug on dev.

  2. Stakeholders demand it on main right now.

  3. Other commits? Unstable, unreviewed. Nope.

  4. You pull the heist:

    git checkout main
    git cherry-pick abc1234
  5. Customers: happy.

  6. You: legend.


Interactive demo

ecommerce-app

Current branch:main

Repository Branches

main
def4562024-01-10
Add user authentication system
alice2 file(s)
abc1232024-01-01
Initial commit
system1 file(s)
develop
jkl0122024-01-16
Add experimental payment feature
charlie2 file(s)
ghi7892024-01-15
Fix authentication bypass vulnerability
bob1 file(s)
def4562024-01-10
Add user authentication system
alice2 file(s)
abc1232024-01-01
Initial commit
system1 file(s)
hotfix
mno3452024-01-17
Critical security patch for auth
security-team1 file(s)
def4562024-01-10
Add user authentication system
alice2 file(s)
abc1232024-01-01
Initial commit
system1 file(s)
Terminal
Initialized git repository for ecommerce-app
Currently on branch: main
$

TL;DR

  • What: Steal a commit like Ocean’s Eleven.

  • How:

    git cherry-pick <hash>
    
  • Why: Hotfixes, targeted changes, branch surgery.


🔥 Next WTF:

“WTF is git rebase (and Why It’s Both Magic and Chaos)”