π
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
- Open the conflicted file in your editor
- Decide what to keep β yours, theirs, or a combination
- Remove all conflict markers
- git add <file>
- 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 commit3. Merge vs Rebase
| Strategy | Result | When |
|---|---|---|
| git merge | Creates a merge commit | Preserve history exactly; teamwork on shared branches |
| git rebase | Replays your commits on top of the base | Keep 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 β