Git & GitHub · Lesson 47 of 144
Merge Conflicts
When Git needs you.
Most merges just work. Git combines changes to different files, or different lines, all on its own. But if two branches change the same line in different ways, Git can't guess which one you want. That's a merge conflict. It's normal, and it's not an error. Git is just asking you to decide.

- Usually, Git merges on its own
- Same line, changed twice?
- Git asks you to decide
Causing a conflict
Here, main changed the page title to Sam's site. And a branch called title changed the same line to my portfolio. We merge title into main. Git says conflict, in index dot HTML, and automatic merge failed. Status lists the file under unmerged paths, both modified.
git
git log --oneline --graph --all -n 4 * 89cd127 (HEAD -> main) Rename site to Sam's Site | * 18e1087 (title) Rename site to My Portfolio |/ * f63a17a Link to about page * ef9c947 Add basic styles git merge title Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. git status On branch main You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")
Summary
A conflict happens when two branches change the same line. Git stops and asks you to choose. Next, how to fix one, step by step.
Key takeaways- Same line, two changes
- CONFLICT: Git stops
- You decide
Next up: Fixing a Conflict — step by step