Apply specific commits from another branch with git cherry-pick (including conflicts and merges)

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

Documented steps

  1. Ensure a clean working tree, then run `git cherry-pick <commit>` — it applies the change that commit introduces and records a NEW commit for it.
  2. Cherry-pick several commits at once: `git cherry-pick a b c`, or a range like `git cherry-pick master~4 master~2` (creates one new commit per source).
  3. To apply all commits on master not yet in HEAD, use `git cherry-pick ..master` (equivalent to `^HEAD master`).
  4. On a conflicting commit, Git sets `CHERRY_PICK_HEAD` and leaves conflict markers; resolve the files, `git add <paths>`, then `git cherry-pick --continue`.
  5. Cancel a problematic pick with `git cherry-pick --abort` (returns to the pre-sequence state and clears `CHERRY_PICK_HEAD`), or skip the current commit with `--skip`.
  6. When backporting between public branches, add `-x` to append a '(cherry picked from commit ...)' trailer for traceability (use `--no-edit` to skip the editor).
  7. To cherry-pick a merge commit you MUST pass `--mainline <parent-number>` (parents numbered from 1) to say which side is the main line.
  8. Official docs: https://git-scm.com/docs/git-cherry-pick

Known gotchas

Related routes

Apply a commit from another branch with git cherry-pick
git-scm.com/git · 7 steps · unrated

Give your agent this knowledge — and 17,000+ 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