Stop 05 · Git & GitHubTopics · 10/11

Conflict Resolution

Part of the Frontend Developer Roadmap

In short

Merge conflicts look scary the first time, with weird arrows all over your file. They're just Git asking one simple question: which version do you want?

The process of manually reconciling two competing changes to the same lines of code when Git can't automatically merge them. Conflicts are not inherently errors; they indicate that Git needs a human to decide how independently changed versions of the same content should be combined.

The jaadu mascot dressed as an umpire compares two clipboards held by two scorers.

Think of it like this

Two scorers, one scoreboard

Two scorers update the same match sheet. One writes 45 runs for Rohit, the other writes 47. The umpire can't guess, so the sheet is held until someone checks and writes the right number. You're that someone.

Watch it happen

Fixing a conflict calmly

git merge
Conflict
Edit file
git add
Commit
Test

1/6You run git merge feature/new-header. Both branches changed the same <h1> line.

The big ideas

What you need to know

Why it happens

Two branches changed the same lines of the same file. Git won't guess which one is right.

Read the markers

<<<<<<< starts your version, ======= splits them, >>>>>>> ends their version.

You decide the final code

Keep yours, keep theirs, or combine both. Then delete all the marker lines.

add marks it resolved

After fixing the file, git add tells Git that conflict is sorted. Then commit or continue.

See it in code

Walk through the code

bash
1git merge feature/new-header2# CONFLICT (content): Merge conflict in index.html3 4# Inside index.html you'll see:5# <<<<<<< HEAD6# <h1>Welcome to InsideEdge</h1>7# =======8# <h1>Find your dream college</h1>9# >>>>>>> feature/new-header10 11# Edit to the final line, delete the markers, then:12git add index.html13git commit                  # completes the merge

1/4The merge stops and Git names the file that has a conflict.

HEAD is the branch you're on. The part after ======= comes from the branch you're merging in. Stuck? git merge --abort takes you back.

Save yourself the pain

Common mistakes

Oops

Committing a file that still has <<<<<<< lines in it.

Do this instead

Search the file for <<<<<<< before you git add. Leftover markers break your code.

Oops

Always picking your own version to finish fast.

Do this instead

Read both sides. Your teammate's change may be important, and the right answer often combines both.

Your mission

Create a conflict on purpose

~20 min

Quick check

You've edited the conflicted file and removed the markers. What tells Git the conflict is resolved?

Go deeper

  1. 1Deliberately create a merge conflict between two branches and resolve it by hand. Validate your understanding by applying it in a small practical example.
  2. 2Learn to read the `<<<<<<<`, `=======`, `>>>>>>>` conflict markers confidently. Focus on understanding the underlying reason it works, not only memorizing the definition.
  3. 3Use your editor's merge conflict UI (VS Code has a good one) instead of raw text editing.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge