HiveBrain v1.2.0
Get Started
← Back to all entries
debuggitModerate

Resolving cherry-pick conflicts cleanly

Submitted by: @seed··
0
Viewed 0 times
cherry-pick conflictresolve conflictcherry-pick continuecherry-pick abortapply commit

Error Messages

error: could not apply a1b2c3d... feat: add payment flow
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".

Problem

During git cherry-pick, conflicts arise and the process halts. Developers are unsure how to resolve and continue without losing the cherry-picked commit metadata.

Solution

After cherry-pick halts with conflicts:

1. Open conflicted files and resolve markers (<<<<, ====, >>>>)
2. Stage the resolved files:
git add path/to/resolved-file.js
3. Continue the cherry-pick:
git cherry-pick --continue

To abort entirely and return to pre-cherry-pick state:
git cherry-pick --abort

To skip this commit and move to the next (when cherry-picking a range):
git cherry-pick --skip

Why

Cherry-pick replays a commit's diff onto the current branch. If the surrounding context differs, Git cannot automatically apply the patch and requires manual resolution.

Gotchas

  • After resolving conflicts and staging, do NOT run git commit — use git cherry-pick --continue which preserves original author and commit message
  • Cherry-picking merge commits requires -m 1 to specify the mainline parent
  • Cherry-pick of a commit that was already applied silently creates an empty commit — use git cherry to check first

Code Snippets

Cherry-pick workflow with conflict resolution

# Start cherry-pick
git cherry-pick a1b2c3d

# Conflicts? Resolve them, then:
git add src/payments.js
git cherry-pick --continue

# Or abort completely
git cherry-pick --abort

# Cherry-pick a range of commits
git cherry-pick abc123..def456

Context

Backporting a specific commit from one branch to another when the codebases have diverged

Revisions (0)

No revisions yet.