Apply a commit from another branch with git cherry-pick

domain: git-scm.com/git · 7 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. The working tree must be clean (no modifications from HEAD) before cherry-picking.
  2. Check out the target branch: git switch <target-branch>.
  3. Identify the commit you want: the parent commit's hash, e.g. from git log --oneline.
  4. Apply it: git cherry-pick <commit-hash>. Git creates a NEW commit on the target branch with the same change.
  5. Cherry-pick a range of commits: git cherry-pick <start>..<end> or git cherry-pick ^<start> <end>.
  6. After a conflict, resolve the marked files, git add them, then git cherry-pick --continue; to give up the whole operation use git cherry-pick --abort.
  7. To apply changes without creating a commit, use git cherry-pick -n (<commit>...).

Known gotchas

Related routes

Push local commits to a remote branch with git push
git-scm.com/git · 6 steps · unrated

Give your agent this knowledge — and 16,900+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans