WeCodeAcademy

Resolving Merge Conflicts

A merge conflict happens when two branches changed the same line. Git cannot choose, so it asks you. It writes both versions into the file between markers.

Examplebash
Open in editor »
/ $

Between <<<<<<< and ======= is your branch; between ======= and >>>>>>> is the other one. To fix it: edit the file to what you want, remove the marker lines, then stage and commit.

Examplebash
Open in editor »
/ $
Quick check

What causes a merge conflict?

Your turn: write the code

Cause a merge conflict on theme.txt (change the same line on two branches and merge), then print how many conflict marker lines (<<<<<<<) the file contains using grep -c.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.