Lesson
Conflicts
Why conflicts happen, how to read markers, and how to complete the merge.
Learning objectives
- Understand what causes a conflict
- Read conflict markers
- Resolve and finish the merge
Overlapping edits
A conflict happens when two branches change the same lines differently since their common ancestor. Git cannot know which version you want, so it asks.
Reading markers
Git inserts markers: <<<<<<< HEAD shows your version, ======= separates, and >>>>>>> shows the incoming version. Edit the file to the final content you want, removing the markers.
Finishing
After editing, git add the file to mark it resolved, then git commit to complete the merge (or git rebase --continue during a rebase).
Try it yourself
Empty folder
Run git init to create a repository.
Working directory
Clean — no uncommitted changes.
Staging area
Nothing staged. Run git add.
Repository
No commits yet.
Merge, resolve the marked file, stage it, and commit to finish.
Commands used
git merge feature
git add conflicted.ts
git commit -m "merge: resolve conflict"Common mistakes
- • Leaving marker lines in the file.
- • Committing without testing the resolved result.
Best practices
- • Resolve conflicts one file at a time.
- • Re-run tests after resolving.
Mini challenge
Resolve a conflict by combining both changes rather than picking one side.
Open the visualizer to try itSummary
- Conflicts come from overlapping edits.
- Markers show both sides.
- Add + commit finishes the merge.