How do you resolve merge conflicts?
Take a moment.
Say your answer out loud or write it down first — retrieval is what makes it stick. Reveal when you're ready.
Short answer
Git marks conflicts with <<<<<<< / ======= / >>>>>>> markers. Open each file, decide the correct combined content, remove markers, git add, then continue the operation (rebase --continue/merge --continue). Understand both sides' intent — never blindly pick one.
Detailed explanation
Conflicts arise when two branches modify overlapping lines, or one deletes what another edits. Git pauses the integration, inserting four-part markers: yours above =======, theirs below, labeled by commit. Resolution means producing what the code *should* say given both intents — sometimes both changes, sometimes one superseding with knowledge of why. Tooling helps: VS Code's inline Accept Current/Mine/Theirs buttons, git meretool, or diff3 context (merge.conflictStyle diff3) showing the common ancestor for smarter judgment. After fixing each file: stage it, then continue — rebase replays remaining commits (later conflicts may recur), merge completes once. Abort cleanly anytime (git merge --abort / rebase --abort). Prevention matters more than cure: small frequent merges of main into long branches, coordinated module ownership, and communication when touching shared files reduce conflict frequency dramatically. Binary/generated files need explicit strategy (ours/theirs).
Example
<<<<<<< HEAD
const timeout = 5000;
=======
const timeout = 10_000;
>>>>>>> feature/configurable-timeout
// Resolved by understanding intent:
const timeout = Number(process.env.TIMEOUT_MS ?? 10_000);
git add config.js
git rebase --continue # or merge --continueInterview tip
Walk the marker anatomy fast, emphasize intent-understanding over side-picking, then close with prevention habits — that arc shows real team experience.
Common mistakes
- Committing files with leftover conflict markers.
- Not knowing --abort escapes cleanly.