Git

Lesson 07

Conflict resolution without overwriting

Resolve conflicts by understanding both sides, then stage only the corrected files instead of blindly taking one version.

Good Code

resolve-conflict.sh
# Read the conflicted file before choosing a resolution.
git status
git diff --merge src/lesson.ts
code src/lesson.ts
npm test
git add src/lesson.ts
git rebase --continue

Bad Code

resolve-conflict.sh
# Taking one side for every file can erase local intent.
git checkout --theirs .
git add .
git rebase --continue
git push --force

Review Notes

What to review

Good Code

The good version identifies conflicted files, compares both sides, edits the resolved file, runs tests, and stages only the resolution.

Bad Code

The bad version takes the other side for every file and force-pushes, which can silently discard local work or domain decisions.

Takeaways

  • A conflict is a design review moment; choosing ours or theirs blindly can delete another person's intent.