git cherry-pick — apply a commit from another branch
Quick Answer
# Find the commit hash
git log --oneline feature-branch
# Apply that commit to the current branch
git cherry-pick abc1234
When to use this
You want to bring a single bug fix or feature commit from another branch without merging everything else on that branch.
Other causes & fixes
Cherry-pick a range of commits
git cherry-pick abc1234..def5678 # applies commits from abc (exclusive) to def (inclusive)
Cherry-pick without committing immediately
Use -n (no-commit) to stage the changes without creating a commit, so you can edit before committing.
git cherry-pick -n abc1234
git status # review staged changes
git commit -m "Applied fix from feature branch"
Resolve conflicts during cherry-pick
# Edit conflicted files, then:
git add .
git cherry-pick --continue
# Or abort entirely:
git cherry-pick --abort
Related