Advanced

How to cherry-pick a commit in Git

Apply a specific commit from one branch to another.

Cherry-pick a single commit
git cherry-pick abc1234

Applies the changes from commit abc1234 to the current branch as a new commit.

When to use: Applying a hotfix from main to a release branch, or vice versa.

Cherry-pick multiple commits
git cherry-pick abc1234 def5678

Applies multiple specific commits to the current branch.

Cherry-pick a range of commits
git cherry-pick abc1234..def5678

Applies a range of commits (not including abc1234, up to and including def5678).

Cherry-pick without auto-committing
git cherry-pick --no-commit abc1234

Applies the changes but does not create a commit. Lets you modify before committing.

Abort cherry-pick
git cherry-pick --abort

Cancels the cherry-pick and returns to the original state.

← Back to Git Reference