Course contentsShow
← Software Engineering
Lesson 655 of 1,93320. Continuous IntegrationFree lesson

The Revert-First Strategy

When and how to revert commits that break the build rather than attempting immediate fixes.

The Revert-First Strategy

You'll learn when to revert a breaking commit instead of rushing to fix it forward.

The Core Principle

When a commit breaks the CI build, you face a choice: fix it forward or revert it. The revert-first strategy means your default action is to revert the breaking commit immediately, restoring the build to green, then fix the problem properly in a new commit.

This might feel counterintuitive—why undo your work? But remember the Green Build Contract: the mainline must stay healthy. Every minute the build stays red blocks other team members from integrating their work confidently.

When to Revert vs Fix Forward

Revert immediately if:

  • The fix will take more than 5-10 minutes to identify and implement
  • You're uncertain what caused the failure
  • The failure affects tests or systems you don't fully understand
  • Other developers are waiting to integrate their work

Fix forward only if:

  • The problem is obvious and trivial (a typo, missing file)
  • You can fix and verify it in under 5 minutes
  • You're absolutely certain your fix won't introduce new issues

Why This Works

Think of CI like a highway. A broken build is a traffic accident blocking all lanes. Reverting is like clearing the wreck to the shoulder immediately—traffic flows again. Fixing forward is like trying to repair the car in the middle of the highway while everyone waits.

Reverting doesn't mean your work was wasted. It means you prioritize team productivity over individual pride. You can fix the issue properly offline, verify it locally, and reintegrate when ready.

Key Takeaway: When in doubt, revert. Keeping the build green matters more than avoiding the temporary step backward—the team's velocity depends on a healthy mainline.