Terminal GuideTerminal Guide

git cherry-pick Command Guide

Apply the changes introduced by some existing commits

6 min readLast updated: January 19, 2026
Dai Aoki

Dai Aoki

CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm

Quick Reference

Basic

git cherry-pick <commit>Pick single commit
git cherry-pick A B CPick multiple
git cherry-pick A..BPick range

Options

-n, --no-commitDon't auto-commit
-e, --editEdit commit message
-xAdd source info to message

Control

--continueContinue after conflict
--abortAbort cherry-pick
--skipSkip current commit

Downloadable Image Preview

Failed to generate preview

Basic Usage

The git cherry-pick command applies the changes from one or more existing commits to your current branch. It's useful for selectively moving commits.

bash
# Cherry-pick a single commit
git cherry-pick abc1234

# Cherry-pick from another branch
git log feature --oneline  # Find the commit
git checkout main
git cherry-pick abc1234

Cherry-picking Multiple Commits

bash
# Pick multiple commits
git cherry-pick abc1234 def5678 ghi9012

# Pick a range (exclusive of first commit)
git cherry-pick abc1234..ghi9012

# Pick a range (inclusive)
git cherry-pick abc1234^..ghi9012

# Pick all commits from a branch
git cherry-pick main..feature
Tip
The range syntax A..B excludes commit A. Use A^..B to include commit A.

Common Options

OptionDescription
-n, --no-commitApply changes without committing
-e, --editEdit the commit message
-xAppend source commit info to message
--continueContinue after resolving conflicts
--abortCancel cherry-pick operation
bash
# Cherry-pick without committing (review first)
git cherry-pick --no-commit abc1234

# Add reference to original commit
git cherry-pick -x abc1234
# Message: "... (cherry picked from commit abc1234)"

# Edit the commit message
git cherry-pick -e abc1234

Handling Conflicts

bash
# When conflicts occur
git cherry-pick abc1234
# CONFLICT: Merge conflict in file.js

# Fix conflicts in the file
# Then stage and continue
git add file.js
git cherry-pick --continue

# Or skip this commit
git cherry-pick --skip

# Or abort entirely
git cherry-pick --abort

Practical Examples

bash
# Backport a fix to release branch
git checkout release-1.0
git cherry-pick abc1234  # The fix commit

# Apply hotfix from main to multiple releases
git checkout release-1.0
git cherry-pick -x abc1234
git checkout release-2.0
git cherry-pick -x abc1234

# Apply multiple related commits
git cherry-pick abc1234 def5678 -n
git commit -m "Combined feature from branch X"

# Cherry-pick from a specific branch
git cherry-pick feature~3  # 3rd commit before tip of feature

Common Use Cases

  • • Backporting bug fixes to release branches
  • • Applying specific commits without merging entire branch
  • • Moving commits to the correct branch
  • • Selective feature deployment

Frequently Asked Questions

What is cherry-picking in Git?

Cherry-picking applies the changes from a specific commit to your current branch. It creates a new commit with the same changes but a different commit hash.

When should I use cherry-pick?

Use cherry-pick to apply specific commits from one branch to another, like backporting a bug fix to a release branch or applying a hotfix from one branch to main.

Does cherry-pick copy or move commits?

Cherry-pick copies commits. The original commit stays on its branch, and a new commit with the same changes is created on your current branch.

What happens if cherry-pick has conflicts?

Git stops and lets you resolve conflicts. After fixing them, run "git add" on resolved files and "git cherry-pick --continue" to finish.

Summary

git cherry-pick lets you apply specific commits across branches. Use -x to track where commits came from.

Quick Reference

  • git cherry-pick <commit> - Pick commit
  • git cherry-pick A..B - Pick range
  • git cherry-pick -n - Without commit
  • git cherry-pick -x - Add source info

Official Documentation

For authoritative information, refer to the official documentation:

Related Articles