What is git cherry-pick?

Why Interviewers Ask This

This is a classic screening question for Git & GitHub roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

git cherry-pick applies the changes from a specific commit (or range of commits) onto the current branch. Instead of merging an entire branch, you pick just the commits you want. Usage: git cherry-pick abc1234 — apply commit abc1234 to the current branch; creates a new commit with the same changes but a different SHA hash. Multiple commits: git cherry-pick abc1234 def5678 — apply two commits; git cherry-pick abc1234..def5678 — apply a range (exclusive of first); git cherry-pick abc1234^..def5678 — range inclusive of first. Options: --no-commit / -n — apply changes without committing (stage only); -e — edit the commit message; -x — append original commit hash to message (useful for tracking). Common use cases: (1) Hotfix — a bug was fixed on a feature branch but needs to go to main immediately; (2) Undo a bad merge — apply only the good commits; (3) Port a specific fix to a release branch. Handle conflicts like merge conflicts. Abort: git cherry-pick --abort. Cherry-pick creates new commits, so the same change exists in multiple branches with different SHAs.

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Git & GitHub candidates.