You will deliberately create a merge conflict, read the conflict markers, and resolve it correctly. By the end conflicts will feel routine rather than scary, and you will know how to back out safely.

Learning Objectives

  • Understand why and when conflicts occur.
  • Read and resolve conflict markers.
  • Verify the merge and abort safely if needed.
  • Time: ~2 hours · Difficulty: Intermediate · Prereqs: the Git fundamentals lab.

Architecture Overview

Environment Setup

You will need: Git and an optional merge tool (VS Code, meld).

Before you begin: conflicts happen when two branches change the same lines; that is normal.

Step-by-Step Execution

01
Trigger a conflict
git merge feature/api
If both branches changed the same lines, Git pauses with a conflict.
02
Read the conflict markers
<<<<<<< HEAD
const port = 8080;   // your change
=======
const port = 3000;   // their change
>>>>>>> feature/api
03
Resolve and complete the merge
$ git add config.js && git commit --no-edit
[main 7f3a] Merge branch 'feature/api'

Progress So Far

Testing & Validation

git status && git diff --check

Status should show a clean tree and diff --check should report no remaining conflict markers. Run your tests to confirm the merge is correct, not just conflict-free.

Troubleshooting
  • Leftover markers committed: git diff --check catches <<<< markers before commit.
  • Resolved the wrong way: the merge is just a commit; revert and redo.
  • Overwhelmed: back out cleanly with git merge --abort and try again.

Extension Ideas

  • Configure a visual mergetool for big conflicts.
  • Reduce conflicts by keeping branches short (see Branching).
  • Catch issues earlier with CI in GitHub Actions.

Key Results

  • Resolved a real conflict by reading the markers.
  • Confirmed zero leftover markers with diff --check.
  • Validated correctness with tests, not just a clean status.
  • Learned to abort and retry without panic.