Skip to content
BENIBIX Learn

Merge Conflict

Development🔀 Version ControlBranches and History

Also known as Git Conflict, Conflict

Two branches changed the same lines, so Git asks you to choose what stays.

Think of it like

Think of it like two people writing on the same line of a card. Someone has to pick what it says.

Example

Jack made the greeting blue and Emma made it red. When they merge, Git shows both lines and Jack picks one.

Why it matters

Conflicts happen on every team. Knowing how to read the markers turns a scary moment into a quick fix.

Definition

A merge conflict happens when two branches change the same lines in different ways. Git cannot guess which version is right, so it stops and asks you. It marks the spot in the file with <<<<<<<, ======= and >>>>>>> lines around both versions. You edit the file to keep what you want, remove the markers and commit. Conflicts are normal and not a sign that anything is broken.

Example code

text
<<<<<<< HEAD
Hello, blue
=======
Hello, red
>>>>>>> red
Your version is above the line of equals signs; the other branch is below.

Common mistake

Committing the file with the markers still in it. The code then breaks, often in a strange way.

Key takeaways

  1. 1
    Same lines, two changes. Git cannot pick for you.
  2. 2
    Markers show both. Yours on top, theirs below.
  3. 3
    Edit, then commit. Remove the markers when done.

Learn it properly