Resolving Merge Conflicts
This is the final lesson of the course, and it's the moment to reassure you once and for all: a merge conflict is not an error and not a failure — it's a completely normal part of teamwork. Most of the time Git merges non-overlapping changes by itself, quietly, without asking you anything. It asks f
A merge conflict is like two people writing in pencil on the same line of one page. Git tries to combine everyone, but on the overlapping line it won't dare to guess — it stacks both versions one above the other and asks you to choose which one stays. The moment you choose and delete the markers — the dispute is over.
- Merge conflict
- When two branches changed the same lines of the same file, so Git can't auto-merge. It marks both versions and asks you to choose. This is normal, not an error.
- Conflict markers
- The lines Git writes into the file: <<<<<<< for the start of your side (HEAD), ======= as the divider, and >>>>>>> for the start of the other side. All three must be deleted at the end.
- HEAD (your side)
- In a conflict, the block between <<<<<<< HEAD and ======= is the version of the branch you're currently on — 'my side'.
- Auto-merge
- When two branches' changes don't touch the same lines, Git merges them by itself without asking. Most merges pass this way quietly, with no conflict at all.
- Resolve
- The process: open the file, choose what stays (one side, the other, or a combination), delete all the markers, then git add <file> and git commit to finish the merge.