Skip to content
Latchkey

GoReleaser "git is currently in a dirty state" in CI

GoReleaser refuses to publish a real release when the git working tree has uncommitted changes, because the release would not correspond to a clean tagged commit. CI often dirties the tree by generating files before the build.

What this error means

GoReleaser stops with "git is currently in a dirty state" and lists the modified or untracked files that appeared during the job.

Terminal
⨯ release failed after 0s
  error=git is currently in a dirty state, please check in your pipeline what
  can be changing the following files:
   M go.sum
  ?? dist/

Common causes

A build step modifies tracked files

Running go mod tidy, code generation, or formatting before GoReleaser changes files like go.sum, dirtying the tree.

Leftover artifacts are untracked

A previous dist/ or generated output left in the checkout appears as untracked files GoReleaser flags.

How to fix it

Keep the tree clean before release

  1. Commit or gitignore any files your pipeline generates (for example dist/).
  2. Run generation and go mod tidy before the tag, not in the release job.
  3. Ensure the release runs against the exact tagged, committed state.
.gitignore
# .gitignore
dist/

Use --snapshot for dirty test builds

For non-publishing CI builds where a dirty tree is acceptable, --snapshot skips the clean-tree requirement.

Terminal
goreleaser release --snapshot --clean

How to prevent it

  • Gitignore build output like dist/ so it never dirties the tree.
  • Run codegen and go mod tidy before tagging, not during release.
  • Use --snapshot for test builds that do not need a clean tree.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →