Skip to content
Latchkey

diff Exit Code 1 in CI: Files Differ (Used by Format Checks)

diff exit code 1 means the two inputs differ - a result, not an error. Format checks rely on this to fail when files are unformatted.

A step exiting 1 from diff (or git diff --exit-code) found differences. Many CI "check" gates use this deliberately.

What it means

diff exits 0 when inputs are identical, 1 when they differ, and 2 on a real error (missing file). git diff --exit-code and prettier --check-style flows use exit 1 as "not formatted / changed".

Common causes

  • Generated output drifted from the committed version.
  • Code is not formatted to the expected style.
  • A "no uncommitted changes" gate found a modified file.

How to fix it

Regenerate or reformat the file and commit it so diff is empty. Treat exit 2 (not 1) as the actual error case. This is deterministic - it reflects the file contents.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →