Last updated
Post-Resolution Checklist
- All
<<<<<<<,=======,>>>>>>>markers removed from every file - Code compiles / passes syntax check
- Logic makes sense — not just syntactically valid but semantically correct
- Tests pass after resolution
- All conflicted files staged with
git add - Merge commit message describes what was resolved
Examples
Example 1: Understanding Conflict Markers
When Git cannot auto-merge, it inserts conflict markers into the file:
<<<<<<< HEAD (current branch — your changes)
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
=======
function calculateTotal(items, taxRate = 0) {
const subtotal = items.reduce((sum, item) => sum + item.price, 0);
return subtotal * (1 + taxRate);
}
>>>>>>> feature/add-tax-support (incoming branch)
The section between <<<<<<< and ======= is your current branch (HEAD). The section between ======= and >>>>>>> is the incoming branch.
Example 2: Three-Way View
The helper shows all three versions — common ancestor, current branch, and incoming branch:
COMMON ANCESTOR (before either branch changed this):
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
CURRENT BRANCH (HEAD) changed:
→ Added item.quantity multiplication
INCOMING BRANCH changed:
→ Added taxRate parameter and tax calculation
Resolution: Combine both changes
function calculateTotal(items, taxRate = 0) {
const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
return subtotal * (1 + taxRate);
}
Example 3: Simple "Keep Both" Conflict
Import statement conflicts almost always resolve by keeping both imports:
<<<<<<< HEAD
import { useState, useEffect } from 'react';
import { formatDate } from '../utils/date';
=======
import { useState, useCallback } from 'react';
import { validateEmail } from '../utils/validation';
>>>>>>> feature/add-email-validation
Resolution — keep all imports:
import { useState, useEffect, useCallback } from 'react';
import { formatDate } from '../utils/date';
import { validateEmail } from '../utils/validation';