skills/coding/git-merge-resolution/SKILL.md
Master git merge conflict resolution: when to merge vs rebase, conflict handling strategies, and maintaining clean merge history. Use when user encounters merge conflicts, git merge issues, or when they need to combine branch histories. Triggers especially when user says "merge conflict", "resolve conflicts", "git merge", "merge strategy", or "conflicts in git".
npx skillsauth add ImaginerLabs/skill-manager git-merge-resolutionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Git-merge-resolution is a behavioral specification skill that encapsulates the judgment of when to merge, how to handle conflicts, and how to maintain clean merge history.
This skill embodies the experience of developers who've merged hundreds of branches and know that most merge conflicts are preventable through strategy, not just resolution.
"Merge conflicts aren't bugs — they're Git's way of saying 'I need a human to make a decision.' The conflict is easy. Deciding WHICH version to keep is the real work."
┌─────────────────────────────────────────────────────────────┐
│ MERGE vs REBASE │
│ │
│ USE MERGE WHEN: │
│ ✓ Merging shared/public branches │
│ ✓ Preserving exact history is important │
│ ✓ Complex conflicts (single merge commit easier) │
│ ✓ Team prefers merge commits │
│ │
│ USE REBASE WHEN: │
│ ✓ Local-only feature branches │
│ ✓ Clean linear history desired │
│ ✓ Regular sync with main (avoid merge bubbles) │
│ ✓ Interactive cleanup before PR │
└─────────────────────────────────────────────────────────────┘
| Situation | Action | Rationale | |-----------|--------|-----------| | Merging main to feature | Rebase OR Merge | Either works | | Merging feature to main | MERGE | Main is shared | | Merging release branch | MERGE | Preserves release point | | Merging hotfix | MERGE | Quick, clear | | Team convention | Follow | Consistency matters |
┌─────────────────────────────────────────────────────────────┐
│ CONFLICT RISK MATRIX │
│ │
│ Low Risk (Merge OK) High Risk (Review First) │
│ ───────────────── ──────────────────────── │
│ • Same files, no overlap • Same files, same lines │
│ • Well-structured commits • Large features merged │
│ • Small changes • Long-running branches │
│ • Good test coverage • Multiple people contributed │
└─────────────────────────────────────────────────────────────┘
# See what changed in target branch
git fetch origin
git log main..origin/main --oneline
# See what changed in your branch
git log origin/main..HEAD --oneline
# Find potential conflict areas
git diff --name-only origin/main...HEAD
# Update all refs
git fetch --all
# Create merge backup branch (safety!)
git branch backup/feature-xyz
# Verify target branch is clean
git checkout target-branch
git status
# Start merge
git checkout feature-branch
git merge main
# If successful (fast-forward or clean)
# Git will create merge commit automatically
# If conflicts occur → resolve then commit
# Fast-forward only (no merge commit)
git merge --ff-only main
# Force merge commit (even if fast-forward possible)
git merge --no-ff main
# Squash merge (all commits into one)
git merge --squash feature-branch
# Ours strategy (keep our version, ignore theirs)
git merge -s ours feature-branch
# Patience strategy (slower but better for renames)
git merge -X patience feature-branch
## What Git Tells You
When conflicts occur, Git shows:
<<<<<<< HEAD (your changes)
const x = 1;
=======
const x = 2;
>>>>>>> feature-branch (their changes)
Git cannot automatically decide because:
- Both versions modified the same lines
- Git doesn't know which is "correct"
Your job: Decide what the final code should be
┌─────────────────────────────────────────────────────────────┐
│ CONFLICT RESOLUTION STEPS │
│ │
│ 1. IDENTIFY: Find conflicting files │
│ git status (shows "both modified") │
│ │
│ 2. UNDERSTAND: What did each side change? │
│ git diff --base conflicted-file │
│ git diff --ours conflicted-file │
│ git diff --theirs conflicted-file │
│ │
│ 3. DECIDE: What should the final code be? │
│ - Ours only? │
│ - Theirs only? │
│ - A combination? │
│ - Something entirely different? │
│ │
│ 4. EDIT: Resolve the conflict markers │
│ <<<<<<< HEAD │
│ [your version] │
│ ======= │
│ [their version] │
│ >>>>>>> feature-branch │
│ Replace with final version, remove markers │
│ │
│ 5. TEST: Verify the resolution │
│ npm test │
│ │
│ 6. STAGE & COMMIT │
│ git add resolved-file │
│ git commit (merge commit auto-created) │
└─────────────────────────────────────────────────────────────┘
# Accept OUR changes completely
git checkout --ours conflicted-file
git add conflicted-file
# Accept THEIR changes completely
git checkout --theirs conflicted-file
git add conflicted-file
# Manual resolution (preferred)
# Edit the file, keeping what makes sense
# Remove conflict markers
# Add when done
git add conflicted-file
# See common ancestor version
git show :1:conflicted-file # common ancestor
# See our version (HEAD)
git show :2:conflicted-file # ours
# See their version
git show :3:conflicted-file # theirs
# Or use git mergetool
git mergetool
# Run tests
npm test
# Check the merge commit
git log -1 --stat
# Verify no missing conflicts
git status
# Build to catch any issues
npm run build
| Issue | Symptom | Fix | |-------|---------|-----| | Lost changes | Tests failing after merge | Check original branch commits | | Inconsistent state | Build errors | Clean rebuild | | Dependencies | Import errors | Reinstall deps |
// CONFICT:
<<<<<<< HEAD
const MAX_RETRIES = 3;
=======
const MAX_RETRIES = 5;
>>>>>>> feature-branch
// RESOLUTION:
// If both are valid, pick larger or add comment
const MAX_RETRIES = 5; // Increased for flaky API
// CONFLICT:
<<<<<<< HEAD
function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
=======
function calculateTotal(items: Item[]): number {
return items
.filter(item => item.active)
.reduce((sum, item) => sum + item.price, 0);
}
>>>>>>> feature-branch
// RESOLUTION: Both changes needed!
// Take the feature's change
function calculateTotal(items: Item[]): number {
return items
.filter(item => item.active)
.reduce((sum, item) => sum + item.price, 0);
}
// CONFLICT:
<<<<<<< HEAD
const API_URL = 'https://api.example.com';
=======
// API_URL was removed
>>>>>>> feature-branch
// RESOLUTION:
// Ask: Should the URL exist or not?
// If feature removed it intentionally → theirs
// If main changed away from it → needs discussion
# Only possible when no divergent commits
git merge --ff-only feature-branch
# Result: No merge commit, just moves pointer
# Good: Clean history
# Bad: No merge record if revert needed
# Always creates merge commit
git merge --no-ff feature-branch
# Result: Merge commit with two parents
# Good: Clear merge record, easy to revert
# Bad: Cluttered history if overused
# Combines all commits into one
git merge --squash feature-branch
git commit -m "feat: complete user authentication"
# Result: Single commit on main
# Good: Very clean history
# Bad: Loses individual commit history
# Git finds common ancestor and combines
git merge feature-branch
# Result: Merge commit if conflicts
# Good: Preserves history
# Bad: Can have complex conflicts
## Strategy: Incremental Merge
Instead of merging feature/entire-overhaul into main at once:
1. Merge small pieces first:
git merge feature/part-1 # Auth
git merge feature/part-2 # User profiles
2. Each merge is smaller, easier to resolve
3. If conflicts between parts, resolve incrementally
4. Final merge to main has less risk
# Option A: Rebase onto main first
git fetch origin
git rebase origin/main
# Resolve conflicts during rebase
# Then merge (likely fast-forward)
# Option B: Merge main into your branch
git fetch origin
git merge origin/main
# Resolve conflicts in your branch
# Then merge to main
# ABORT the merge
git merge --abort
# Start fresh
git checkout feature-branch
git merge main
# Or restore from backup
git checkout -b restored-feature backup/feature-xyz
MERGE RESOLUTION CHECKLIST
==========================
PRE-MERGE:
□ Fetched and updated branches
□ Reviewed what changed in each branch
□ Created backup branch
□ Verified clean working directory
□ Assessed conflict risk
DURING:
□ Identified all conflicting files
□ Understood what each side changed
□ Made conscious decision on each conflict
□ Tested resolution compiles/runs
□ No conflict markers left
POST-MERGE:
□ Run full test suite
□ Review merge commit message
□ Verify no unintended changes
□ Push if ready
□ Notify team of significant changes
Don't just pick "ours" or "theirs" blindly. Understand what each version does and why.
Merging 5 small commits is safer than merging 1 large one.
Just because it compiles doesn't mean it's right. Run tests.
If merging branches from teammates, talk to them about conflicting changes.
Don't leave conflicts staged. Commit the merge to complete it.
# BAD: Just taking all ours or all theirs
git checkout --ours .
git add .
# This loses work!
# GOOD: Evaluate each conflict
// BAD: Still has markers
<<<<<<< HEAD
const x = 1;
=======
const x = 2;
>>>>>>> feature-branch
// Must remove these before committing!
# BAD: "Looks fine, pushing..."
git commit -m "Merge"
git push
# Tests fail in CI
# GOOD: Always test before pushing
npm test
git-branch-strategy — Branch planning affects merge frequencygit-rebase-safety — Alternative to merge for local branchesgit-history-rewrite — Cleaning up history before mergepre-commit-review — Review after mergegit-stash-management — Stashing during merge interruptionsdevelopment
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.