Understanding Git Merge Conflicts Through Conflict Markers

Understanding Git Merge Conflicts Through Conflict Markers

May 26, 2026

Merge conflicts sound more dramatic than they usually are. In most cases, Git is simply saying:

I found two valid versions of the same area, and I need a human to decide the final version.

This often happens when a feature branch and main both modify nearby lines in the same file. It can also happen when one branch edits something that another branch deletes.

What Conflict Markers Mean

When Git cannot merge automatically, it writes conflict markers into the file:

<<<<<<< HEAD
version from your current branch
=======
version from the branch being merged
>>>>>>> main

The structure is simple:

  • <<<<<<< HEAD starts your current branch’s version
  • ======= separates the two versions
  • >>>>>>> main ends the other branch’s version

Your job is to replace the whole marked section with the final content you actually want.

A Simple Example

Suppose the original file had this line:

Button color: blue

Your feature branch changed it to:

Button color: green

Meanwhile, main changed it to:

Button color: red

When Git tries to merge, it may produce:

<<<<<<< HEAD
Button color: green
=======
Button color: red
>>>>>>> main

Git is not saying either version is wrong. It is saying both branches changed the same area, and the final decision needs intent.

You could keep your version:

Button color: green

Or keep main’s version:

Button color: red

Or choose something else:

Button color: purple

After deciding, remove the marker lines.

Conflicts Are Not Only Same-Line Edits

A common misunderstanding is that conflicts happen only when two branches edit the exact same line. That is not always true.

Conflicts can also happen when one branch edits a block and another branch deletes that same block.

For example, the original file had:

<section class="banner">
  <h2>Holiday Sale</h2>
  <p>Everything is 20% off this week.</p>
</section>

Your feature branch changed the text:

<section class="banner">
  <h2>Holiday Sale</h2>
  <p>Everything is 30% off this week.</p>
</section>

But main deleted the banner entirely:

Git cannot know whether the final page should keep the updated banner or remove the banner. So it may produce:

<<<<<<< HEAD
<section class="banner">
  <h2>Holiday Sale</h2>
  <p>Everything is 30% off this week.</p>
</section>
=======
>>>>>>> main

Here, the main side is empty because main deleted that block.

If the banner should stay, keep the block. If the banner was intentionally removed, delete the whole conflict block.

How To Resolve A Conflict

The process is usually:

git status

Open the conflicted file and search for:

<<<<<<<

Edit the file into the final version you want.

Then stage it:

git add path/to/file

And continue the merge:

git commit

Or, during a rebase:

git rebase --continue

The Real Skill

Resolving conflicts is less about Git syntax and more about understanding intent.

Ask:

  • Which branch represents the accepted behavior?
  • Was this block intentionally changed or removed?
  • Can both changes coexist?
  • Is one change stale because the other branch moved the code forward?

Git shows the mechanical disagreement. The developer resolves the product decision.

Conflict markers are not errors to fear. They are just Git’s way of pausing before it guesses wrong.