1. What Is Cherry-Pick

Cherry-pick allows you to take one or more specific commits from a branch and apply them on top of another branch.

Instead of merging the whole branch, you selectively pick only the commits you need.

Useful in cases like:


2. How Cherry-Pick Works (High-Level)

Imagine this simple commit history:

main:      A -- B -- C
feature:         B -- C -- D -- E

If you want only commit D from feature to be applied on main:

main after cherry-pick:
A -- B -- C -- D

Commit D' is a new commit based on D, but applied on main.


3. Step-by-Step Workflow

Step 1: Identify the commit hash

Switch to the branch containing the commit and view the log.

git checkout feature
git log