How to fix error: could not apply abc1234... commit message CONFLICT (content): Merge conflict in <file> in Git

GitINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 212 views

Cherry-pick conflicts occur when Git cannot automatically apply a commit's changes to your current branch. This happens when the same lines have been modified differently, requiring manual conflict resolution.

Quick fix

Fixes error: could not apply abc1234... commit message CONFLICT (content): Merge conflict in <file>

git status
  1. Identify conflicting files
  2. Open conflicting files and locate conflict markers
  3. Resolve conflicts by editing the files
  4. Stage the resolved files
git โ€” error
git status
error: could not apply abc1234... commit message
CONFLICT (content): Merge conflict in <file>

What this error means

The "error: could not apply" message followed by "CONFLICT (content)" indicates that Git's cherry-pick operation encountered conflicting changes and cannot proceed automatically. Cherry-picking is fundamentally different from merging. While a merge looks for a common ancestor (merge-base) to combine histories, cherry-pick simply takes a single commit and attempts to replay the changes it introduced onto your current branch. Git essentially creates a patch from that commit and applies it - without considering the history of where the commit came from. When Git applies this patch, it compares the "before" and "after" states of the cherry-picked commit against your current branch. If your branch has different content in the same location where the patch expects to make changes, Git cannot determine the correct result automatically. It marks these locations as conflicts and pauses the cherry-pick, leaving you to resolve them manually. This error is common when cherry-picking commits between branches that have diverged significantly, when picking commits out of order, or when the same bug was fixed differently in multiple branches.

Typical symptoms

  • Cherry-pick command exits with 'error: could not apply' message
  • Terminal shows 'CONFLICT (content): Merge conflict in <filename>'
  • Running 'git status' shows files under 'Unmerged paths' with 'both modified' status
  • Conflict markers (<<<<<<, =======, >>>>>>>) appear in affected files
  • Cherry-pick stops mid-operation and waits for conflict resolution

Common causes

  1. The cherry-picked commit modifies lines that have been changed differently in your current branch
  2. Cherry-picking commits out of chronological order, where later commits depend on earlier ones
  3. The surrounding code context has changed, preventing Git from finding where to apply the patch
  4. The same fix was implemented differently in both branches
  5. Intermediate commits were skipped that the cherry-picked commit depends on
  6. Line endings or whitespace differences between branches

How to fix "error: could not apply abc1234... commit message CONFLICT (content): Merge conflict in <file>"

1Identify conflicting files

First, see which files have conflicts that need resolution:

bash
git status

Look for files listed under "Unmerged paths" with the status "both modified":

bash
Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   src/utils.js
        both modified:   config.yml

These are the files you need to fix manually.

2Open conflicting files and locate conflict markers

Open each conflicting file in your editor. Git inserts conflict markers showing both versions:

bash
<<<<<<< HEAD
// Your current branch's version
const result = processData(input);
=======
// The cherry-picked commit's version
const result = transformData(input);
>>>>>>> abc1234 (commit message)

The section between <<<<<<< HEAD and ======= is your current branch's code. The section between ======= and >>>>>>> is from the commit being cherry-picked.

3Resolve conflicts by editing the files

Decide which code to keep, combine both changes, or write something entirely new. Remove all conflict markers when done:

javascript
// After resolution - keep one version, combine both, or write new code
const result = transformData(input); // chose the cherry-picked version

For complex conflicts, consider using a visual merge tool:

bash
# Use your configured merge tool
git mergetool

# Or configure one first
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd 'code --wait $MERGED'
4Stage the resolved files

After resolving conflicts in each file, stage them to mark them as resolved:

bash
# Stage individual files
git add src/utils.js
git add config.yml

# Or stage all resolved files at once
git add .

Verify all conflicts are resolved:

bash
git status

You should no longer see any files under "Unmerged paths".

5Continue the cherry-pick operation

Once all conflicts are resolved and staged, complete the cherry-pick:

bash
git cherry-pick --continue

Git will open your editor to confirm or modify the commit message. Save and close to finish. The cherry-picked commit is now applied to your branch.

6Alternative: Use automatic resolution strategies

For bulk cherry-picks where you know you want one side's changes, use merge strategies:

bash
# Keep the cherry-picked commit's changes on conflict
git cherry-pick --strategy=recursive -X theirs <commit>

# Keep your branch's changes on conflict
git cherry-pick --strategy=recursive -X ours <commit>

Warning: These options resolve ALL conflicts one way. Only use when you're certain you don't need to manually inspect each conflict.

7Abort if something goes wrong

If you need to abandon the cherry-pick and return to your previous state:

bash
git cherry-pick --abort

This completely undoes the cherry-pick attempt, discarding any conflict resolutions you made. Your branch returns to exactly how it was before you started.

You can also skip just this one commit if cherry-picking multiple:

bash
git cherry-pick --skip
8Prevent future conflicts with rerere

Enable Git's "reuse recorded resolution" feature to remember how you resolved conflicts:

bash
# Enable rerere globally
git config --global rerere.enabled true

Once enabled, if you encounter the same conflict again in the future, Git will automatically apply your previous resolution. This is especially useful when you frequently cherry-pick between long-lived branches.

Advanced notes

### Why Cherry-Pick Conflicts Differ from Merge Conflicts

Cherry-pick conflicts can occur even when a normal merge would succeed. This is because merge uses three-way merge with a common ancestor, while cherry-pick only uses two-way comparison. Git cannot "see" the shared history, so changes that are logically compatible may still produce conflicts.

### Cherry-Picking Multiple Commits

When cherry-picking a range of commits, conflicts may compound. Consider cherry-picking them together so that later commits can resolve conflicts from earlier ones:

bash
# Cherry-pick a range
git cherry-pick abc1234..def5678

# Or list specific commits
git cherry-pick abc1234 def5678 ghi9012

### The -x Flag for Traceability

When cherry-picking, use -x to append a note showing the original commit hash:

bash
git cherry-pick -x abc1234

This adds "(cherry picked from commit abc1234...)" to the commit message, making it easier to track the source of changes. Note: This only works for cherry-picks without conflicts.

### Cherry-Picking Merge Commits

Regular merge commits cannot be cherry-picked without specifying which parent to use:

bash
# -m 1 uses the first parent (usually the branch being merged into)
git cherry-pick -m 1 <merge-commit-hash>

### IDE and GUI Support

Most Git GUIs provide visual conflict resolution:
- VS Code: GitLens extension or built-in Source Control
- IntelliJ/WebStorm: Built-in Git integration with 3-way merge
- GitKraken, Sourcetree, Fork: Visual merge conflict editors

These tools show both versions side-by-side and let you choose changes interactively.

Frequently asked questions

What does "error: could not apply abc1234... commit message CONFLICT (content): M" mean?
The "error: could not apply" message followed by "CONFLICT (content)" indicates that Git's cherry-pick operation encountered conflicting changes and cannot proceed automatically. Cherry-picking is fundamentally different from merging. While a merge looks for a common ancestor (merge-base) to combine histories, cherry-pick simply takes a single commit and attempts to replay the changes it introduced onto your current branch.
How do I fix "error: could not apply abc1234... commit message CONFLICT (content): M"?
Cherry-pick conflicts occur when Git cannot automatically apply a commit's changes to your current branch. This happens when the same lines have been modified differently, requiring manual conflict resolution.
What causes "error: could not apply abc1234... commit message CONFLICT (content): M"?
The cherry-picked commit modifies lines that have been changed differently in your current branch Cherry-picking commits out of chronological order, where later commits depend on earlier ones The surrounding code context has changed, preventing Git from finding where to apply the patch
Is the "error: could not apply abc1234... commit message CONFLICT (content): M" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading