Ch. 16 · Git & CI/CD

Git Conflict Resolution and Combined Intent

Git Conflict Resolution and Combined Intent. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

Conflicts identify changes Git cannot combine automatically. Resolution must preserve intended behavior, not merely remove markers.

Before you start

You should understand commits, branches, the working tree and the staging area. Draw the commit graph before changing history. Try commands in a disposable repository with a clean working tree so you can observe exactly which references and files each operation changes.

The practical goal is to reason through this situation: Two branches modify validation rules; the resolved code must satisfy both valid requirements. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Read both intents

Determine why each branch changed the conflicting region.

Step 2: Resolve behavior

Combine compatible requirements rather than only deleting conflict markers.

Step 3: Review and validate

Inspect the combined diff and exercise affected behavior before completion.

Worked scenario

Two branches modify validation rules; the resolved code must satisfy both valid requirements.

One branch rejects empty names; another trims whitespace. Choosing either whole file can lose the other’s rule. The intended resolution trims first and rejects an empty normalized result if both requirements apply. A syntactically clean merge does not prove that both behaviors survived.

Common mistake

Choosing ours or theirs for an entire file can discard unrelated work.

Verify the behavior

Test ordinary names, empty input and whitespace-only input after resolution.

Interview exercise

Verify a resolution.

Answer and reasoning

Read surrounding code, inspect the combined diff and run the affected behavior checks before completing the merge.

Continue learning

Compare the scenario with the Git and CI/CD interview questions and test your understanding with the Git and CI/CD MCQs. For terminology and implementation details, consult the reference material.

More in Git & CI/CD

read ✓Git & CI/CD · easy

Git Detached HEAD

What a detached HEAD is, when it happens, and how to keep commits made in that state.

~2 min readread →
read ✓Git & CI/CD · mid

Git Hooks and Local Automation

Automate checks with client and server hooks, share them through a framework, and enforce the same rules in CI where they cannot be bypassed.

~2 min readread →
read ✓Git & CI/CD · hard

Git LFS for Large Files

Track large binaries with Git LFS, keep pointer files in the repository, and plan for LFS storage and access.

~2 min readread →
esc