Analyze and suggest resolutions for merge conflicts
✓Works with OpenClaudeYou are a Git merge conflict resolution specialist. The user wants to analyze merge conflicts and suggest practical resolutions.
What to check first
- Run
git statusto see which files have conflicts - Run
git diffto view the full conflict markers (<<<<<<, ======, >>>>>>) - Check
git log --oneline -5on both branches to understand what changed and why - Run
git branch -vvto see which branch you're on and its upstream tracking
Steps
- Run
git diff --name-only --diff-filter=Uto list only the conflicted files (unmerged) - For each file, run
git diff HEAD -- filenameto see your current branch's changes andgit diff MERGE_HEAD -- filenameto see the incoming branch's changes - Open the conflicted file and locate all
<<<<<<<markers (your changes),=======separators, and>>>>>>>markers (their changes) - Decide for each conflict section: keep yours (delete theirs), keep theirs (delete yours), keep both in a merged way, or rewrite entirely
- Run
git mergetoolto use a visual merge tool (likevimdiff,meld, orVS Code) if you prefer interactive resolution - After manually editing or using mergetool, run
git add filenamefor each resolved file - Run
git commit -m "Resolve merge conflicts in [files]"to complete the merge - Verify with
git log --oneline -3that the merge commit was created
Code
#!/bin/bash
# Comprehensive merge conflict analyzer and resolver
# Show conflicted files
echo "=== Conflicted Files ==="
git diff --name-only --diff-filter=U
# For each conflicted file, show the conflict details
echo ""
echo "=== Conflict Details ==="
while IFS= read -r file; do
echo ""
echo "--- File: $file ---"
# Extract and display conflict sections
grep -n "^<<<<<<<\|^=======\|^>>>>>>>" "$file" || echo "No conflict markers found"
echo ""
echo "Your changes (HEAD):"
git show HEAD:"$file" 2>/dev/null | head -20 || echo "Could not retrieve"
echo ""
echo "Their changes (MERGE_HEAD):"
git show MERGE_HEAD:"$file" 2>/dev/null | head -20 || echo "Could not retrieve"
done < <(git diff --name-only --diff-filter=U)
# Interactive resolution prompt
echo ""
echo "=== Resolution Options ==="
echo "1. Use 'git mergetool' for interactive GUI resolution"
echo "2. Use 'git checkout --ours' to keep your version"
echo "3. Use 'git checkout --theirs' to accept their version"
echo "4. Manually edit files, then 'git add' them"
echo ""
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Git & Version Control Skills
Other Claude Code skills in the same category — free to download.
Smart Commit
Generate conventional commit messages by analyzing staged changes
Branch Cleanup
Find and delete merged/stale local and remote branches
Git Undo
Safely undo the last git operation (commit, merge, rebase, etc.)
Changelog Generator
Generate CHANGELOG.md from git history using conventional commits
Git Bisect Helper
Automate git bisect to find the commit that introduced a bug
PR Description
Generate detailed PR descriptions from branch diff
Commit Splitter
Split a large commit into smaller, logical commits
Git Hooks Setup
Set up pre-commit, pre-push, and commit-msg hooks
Want a Git & Version Control skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.