A workflow, not a panic
Conflicts are routine. The right workflow turns them from a stress event into a five-minute task: inspect, decide, edit, verify, continue. This page lays out the discipline.
Step 1: inspect
git status # which files conflict
git diff --name-only --diff-filter=U
git log --merge -p path/to/file # commits unique to each side
--merge shows only commits relevant to the unmerged path on each side, dramatically narrowing the search.
Step 2: choose strategy
Decide per file: keep ours, keep theirs, or merge by hand. For binary files, choose one side wholesale; line-merging makes no sense:
git checkout --theirs assets/logo.png
git add assets/logo.png
Step 3: edit
For text, edit the conflict markers. Configure merge.conflictStyle = zdiff3 (Git 2.35+) to see the ancestor inline. Remove all markers; git diff --check warns about leftovers.
git config --global merge.conflictStyle zdiff3
git diff --check
Step 4: verify
Build and test before staging. Conflicts that compile can still be semantically wrong — review with eyes on full context.
cargo test
git add path/to/file
git status
Step 5: continue
git merge --continue
git rebase --continue
git cherry-pick --continue
Or abort if you got in over your head:
git merge --abort
git rebase --abort
Tools that help
git mergetoolwith meld, kdiff3, p4merge, vimdiff, beyond compare, IntelliJ.git rerereto replay resolutions on repeated rebases — see "Rerere: automatic conflict resolution reuse".git imergefor incremental, bisect-style merging of long-divergent branches.
Patterns
Conflicting whitespace? Try git merge -X ignore-all-space. Repeated changelog conflicts? Mark CHANGELOG.md merge=union in .gitattributes. Lockfile conflicts? Run a custom driver that regenerates them — see "Custom merge strategies and drivers".
Common mistakes
Resolving in the editor without inspecting git log --merge — you miss the why. Committing a half-resolved file because the markers are gone but the logic is wrong. Skipping tests because "it compiles." Force-pushing the result without telling collaborators.
Related
See "Three-way diff and conflict resolution strategies", "Custom merge strategies and drivers", and "Rerere: automatic conflict resolution reuse".