denoland/deno · error

Aborting due to uncommitted changes. Check in source code or

Error message

Aborting due to uncommitted changes. Check in source code or run with --allow-dirty

What it means

Before uploading, `deno publish` verifies the git repository is clean so every published version maps to a checkable commit. If the worktree has uncommitted changes and neither `--allow-dirty` nor the `DENO_TESTING_DISABLE_GIT_CHECK` env var applies, it prints the change summary via `log::error!` and aborts. The check runs against the repo containing the initial cwd.

Source

Thrown at cli/tools/publish/mod.rs:200

      publish_configs,
    )
    .await?;

  diagnostics_collector.print_and_error()?;

  if prepared_data.package_by_name.is_empty() {
    bail!("No packages to publish");
  }

  if std::env::var("DENO_TESTING_DISABLE_GIT_CHECK")
    .ok()
    .is_none()
    && !publish_flags.allow_dirty
    && let Some(dirty_text) =
      check_if_git_repo_dirty(cli_options.initial_cwd()).await
  {
    log::error!("\nUncommitted changes:\n\n{}\n", dirty_text);
    bail!(
      "Aborting due to uncommitted changes. Check in source code or run with --allow-dirty"
    );
  }

  if publish_flags.dry_run {
    for (_, package) in prepared_data.package_by_name {
      log::info!(
        "{} of {} with files:",
        colors::green_bold("Simulating publish"),
        colors::gray(package.display_name()),
      );
      for file in &package.tarball.files {
        log::info!("   {} ({})", file.specifier, human_size(file.size as f64),);
      }
    }
    log::warn!("{} Dry run complete", colors::green("Success"));
    return Ok(());
  }

View on GitHub (pinned to f7822238ca)

Solutions

  1. Commit or stash the changes first: `git add -A && git commit -m "chore: release"`.
  2. If the dirtiness is expected (CI-generated artifacts), re-run with `deno publish --allow-dirty`.
  3. Add generated paths to .gitignore so they stop marking the tree dirty in future runs.

Example fix

# before
deno publish   # error: uncommitted changes
# after
git add -A && git commit -m "chore: release v1.2.3" && deno publish
# or, in CI with generated files:
deno publish --allow-dirty
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
if [ -n "$(git status --porcelain)" ]; then
  echo "dirty worktree — commit, stash, or use --allow-dirty" >&2
  git status --porcelain >&2
  exit 1
fi
deno publish

Prevention

When it happens

Trigger: Running `deno publish` (no `--allow-dirty`) while `check_if_git_repo_dirty` finds the tree differs from HEAD — uncommitted edits, staged changes, or untracked files counted by git status.

Common situations: CI pipelines that generate files (lockfiles, dist output, changelogs) before the publish step; local releases where the version bump was edited but not committed; bots mutating the tree.

Related errors


AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20). Data as JSON: /api/errors/b7200a04ff955212. Report an issue: GitHub.