# git cherry-pick: Usage, Options & Common CI Errors

> git cherry-pick applies the changes from specific commits onto the current branch. Reference for -x, -n, ranges, --continue, and conflict errors in CI.

Source: https://latchkey.dev/learn/command-reference/git-cherry-pick  
Updated: 2026-06-25

git cherry-pick copies the changes from one or more commits onto your current branch as new commits.

Cherry-pick is how you port a fix to another branch. Conflicts pause it, like a rebase.

## What it does

git cherry-pick takes the diff introduced by each named commit and applies it on top of the current HEAD, creating a new commit for each.

## Common usage

```Terminal
git cherry-pick <sha>
git cherry-pick -x <sha>          # add "cherry picked from" note
git cherry-pick A^..B             # a range of commits
git cherry-pick -n <sha>          # apply without committing
git cherry-pick --continue
```

## Options

| Flag | What it does |
| --- | --- |
| -x | Append a "cherry picked from commit" line |
| -n / --no-commit | Apply changes without committing |
| -m <parent> | Pick a merge commit, choosing the mainline |
| --continue / --abort / --skip | Manage an in-progress pick |

## Common errors in CI

error: could not apply <sha>… / "after resolving the conflicts, mark them with git add … then run git cherry-pick --continue" - the pick conflicts. Resolve and continue, --skip to drop the commit, or --abort to bail. Picking a merge needs -m.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git cherry-pick: Usage, Options & Common CI Errors?

Cherry-pick is how you port a fix to another branch. Conflicts pause it, like a rebase.

### What it does?

git cherry-pick takes the diff introduced by each named commit and applies it on top of the current HEAD, creating a new commit for each.

### Common errors in CI?

error: could not apply <sha>… / "after resolving the conflicts, mark them with git add … then run git cherry-pick --continue" - the pick conflicts. Resolve and continue, --skip to drop the commit, or --abort to bail. Picking a merge needs -m.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
