Skip to content
Latchkey

CI "generated files differ, run make generate" git diff gate in CI

A common CI gate runs the codegen command, then git diff --exit-code over the generated files. A non-empty diff means the committed generated code does not match what the current source produces, so the job fails and tells you to regenerate.

What this error means

The job prints a diff of generated files and fails with a message like "generated files are out of date, run make generate and commit", exiting non-zero on git diff --exit-code.

CI
+ git diff --exit-code gen/
diff --git a/gen/api.pb.go b/gen/api.pb.go
@@
-  // outdated generated content
+  // regenerated content
Error: generated files differ. Run 'make generate' and commit the result.

Common causes

Source changed but generated code was not regenerated

A .proto, schema, or spec changed and the author did not re-run codegen, so the committed output is stale.

A different generator or plugin version in CI

CI uses a different version of the generator than the author, so the regenerated output differs even without a source change.

How to fix it

Regenerate and commit the output

  1. Run the project codegen command locally.
  2. Commit the regenerated files so they match the source.
  3. Push, and the diff gate passes.
Terminal
make generate
git add -A
git commit -m "Regenerate generated code"

Pin generator and plugin versions everywhere

Make CI and local use the exact same tool versions so identical source always produces identical output.

.github/workflows/ci.yml
- name: Check generated code is up to date
  run: |
    make generate
    git diff --exit-code

How to prevent it

  • Pin codegen tool and plugin versions across local and CI.
  • Run codegen in a pre-commit hook so output never drifts.
  • Keep one documented make generate target as the source of truth.

Frequently asked questions

What causes ""generated files differ""?
A .proto, schema, or spec changed and the author did not re-run codegen, so the committed output is stale.
How do I fix "generated files differ"?
Regenerate and commit the output

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card