The most detailed free FDE + DevOps library: 140+ lessons, 70+ labs and 80 long-form articles, in English and Turkish. Start learning →

Merge conflicts that keep behavior: resolve with tests

Updated

A forest trail splitting into two paths

Resolve conflicts by behavior, not by lines: run the tests before and after, keep both intentions visible.

Conflict markers show lines; the real conflict is intentions. Two branches changed the same code for different reasons, and picking lines at random keeps neither reason. Resolve by behavior: understand both, combine, prove with tests.

Both intentions, then tests

Read both sides first. What was each branch trying to do? The answer is in commit messages and tests, not in the markers.

Combine, do not choose. Keep both behaviors working where they do not contradict; where they contradict, decide explicitly and write why.

Test the combination. The merged result runs the full relevant suite plus a new test for the feared behavior. Green means resolved; red means you misunderstood a side.

Worked example: a fictional checkout conflict

The context below is fictional. Two ParcelTrack branches (fictional) touch fee calculation: one adds a discount, one adds a surcharge. Markers offer a coin flip.

The resolver reads both tests, keeps both rules with explicit precedence, and adds a combined test with both discount and surcharge. Green suite, both behaviors alive, precedence documented.

Checklist: a merge that holds

  1. Both intentions understood from commits and tests.
  2. Combination decided explicitly, not by marker order.
  3. New test guards the feared behavior.
  4. Full relevant suite green after resolution.

Straight answers

Frequently asked questions

Take mine or theirs?

Neither blindly. Read both intentions, combine them, and let the tests judge the result.

Tests pass but I am unsure?

Add a test for the behavior you feared losing, then merge. Uncertainty is a missing test wearing a conflict costume.

How do I prevent monster conflicts?

Small frequent merges. A week-old branch conflicts with everything; a day-old branch conflicts with little.

Bu sayfanın Türkçesi

Turn reading into a credential

This post is a free field note. Exams run at dated sittings in 15-seat classes; one price covers one attempt. All lessons are free.