Quiz
Warm-up from lesson 5-3. During a true merge, when does Git combine both branches automatically without asking you anything?
The one case Git can't decide
You changed line 2 of cake.txt on main. Your teammate's branch also changed line 2, differently. Merge them and Git faces two competing truths with no way to know which one you want. It refuses to guess:
$ git merge brown-butter Auto-merging cake.txt CONFLICT (content): Merge conflict in cake.txt Automatic merge failed; fix conflicts and then commit the result.
This is a merge conflict. Two things to internalize before anything else:
- Nothing is broken or lost. Both versions are safely in their commits. Git has simply paused the merge and is waiting for a human decision.
- Conflicts are routine. On a team they happen weekly. Senior engineers read the message and calmly fix it in two minutes, and by the end of this unit you will too.
Reading the conflict markers
Git rewrites the conflicted file to show both versions, fenced by marker lines. Open cake.txt and you'd see:
Preheat oven to 180C <<<<<<< HEAD Add regular butter ======= Add brown butter >>>>>>> brown-butter Bake for 25 minutes
Decoding it:
<<<<<<< HEADstarts your side: what the line looks like where you stand (HEAD, your current branch, here main).=======is the divider between the two versions.>>>>>>> brown-butterends their side: the incoming branch's version.- Everything outside the markers (
Preheat...,Bake...) merged fine and needs no attention.
The conflict is only the marked region. A 500-line file with one conflicted line needs one decision, not 500.
Quiz
In a conflicted file, what does the ======= line separate?
Problem
Git marks a conflict with three special line prefixes. Which one begins the section showing YOUR current branch's version?