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.
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.
First, see which files have conflicts that need resolution:
git statusLook for files listed under "Unmerged paths" with the status "both modified":
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: src/utils.js
both modified: config.ymlThese are the files you need to fix manually.
Open each conflicting file in your editor. Git inserts conflict markers showing both versions:
<<<<<<< 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.
Decide which code to keep, combine both changes, or write something entirely new. Remove all conflict markers when done:
// After resolution - keep one version, combine both, or write new code
const result = transformData(input); // chose the cherry-picked versionFor complex conflicts, consider using a visual merge tool:
# 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'After resolving conflicts in each file, stage them to mark them as resolved:
# 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:
git statusYou should no longer see any files under "Unmerged paths".
Once all conflicts are resolved and staged, complete the cherry-pick:
git cherry-pick --continueGit 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.
For bulk cherry-picks where you know you want one side's changes, use merge strategies:
# 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.
If you need to abandon the cherry-pick and return to your previous state:
git cherry-pick --abortThis 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:
git cherry-pick --skipEnable Git's "reuse recorded resolution" feature to remember how you resolved conflicts:
# Enable rerere globally
git config --global rerere.enabled trueOnce 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.
### 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:
# 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:
git cherry-pick -x abc1234This 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:
# -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.
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git