← Back to the Build Your Homepage series
πŸ”€
EPISODE 02
merge Β· rebase Β· conflict markers Β· tooling

Resolving Conflicts

Conflicts are part of working with others. Learn to read conflict markers, choose between merge and rebase, and use VS Code's three-way merge tool.

conflictmergerebasethree-way
Duration
⏱ About 1.5 hours
Level
πŸ“Š Intermediate
Prerequisite
🎯 git-coop-01
OUTCOME
Resolve conflicts confidently without losing changes

What you'll learn

  • 1Read <<<<<<<, =======, >>>>>>> conflict markers
  • 2Resolve a merge conflict step by step
  • 3Choose between merge and rebase intentionally
  • 4Use VS Code's merge editor

1. What a Conflict Looks Like

text
<<<<<<< HEAD (current branch)
const greeting = "Hello, world!";
=======
const greeting = "Hi, world!";
>>>>>>> feature/branch
  • <<<<<<< HEAD β€” your current branch's version
  • ======= β€” the divider
  • >>>>>>> branch-name β€” the incoming branch's version

2. Resolve

  1. Open the conflicted file in your editor
  2. Decide what to keep β€” yours, theirs, or a combination
  3. Remove all conflict markers
  4. git add <file>
  5. git commit (merge commit message is auto-filled)
bash
git status                    # see conflicted files
git diff --name-only --diff-filter=U   # only conflicts
# ... edit each one ...
git add path/to/file
git commit

3. Merge vs Rebase

StrategyResultWhen
git mergeCreates a merge commitPreserve history exactly; teamwork on shared branches
git rebaseReplays your commits on top of the baseKeep history linear; only on your own branch
⚠️

Never rebase a branch others have based work on β€” it rewrites history and breaks everyone else.

4. Tooling

  • VS Code shows "Accept Current / Incoming / Both" buttons inline
  • git mergetool β€” opens your configured merge tool
  • git rerere β€” remembers resolutions for similar future conflicts
Example code / lecture materials

All lecture materials and example code are openly available on GitHub.

View on GitHub β†—