nikivdev/code · error
refusing to bootstrap dirty repo {} during clone bootstrap
Error message
refusing to bootstrap dirty repo {} during clone bootstrap What it means
During clone bootstrap, if the cloned repo's working tree is dirty and options.fail_on_dirty is set, bootstrap refuses to proceed rather than operating on uncommitted changes. This protects against stashing/committing/resetting user changes implicitly.
Source
Thrown at src/repos.rs:816
let mut status = repo_home_branch_status_with_options(
repo_root,
&options.home_branch,
options.ensure_private_mirror,
)?;
if !status.eligible {
let result = HomeBranchBootstrapResult {
repo_root: repo_root.display().to_string(),
changed: false,
switched_to_home_branch: false,
status,
steps: vec!["skipped: repo is not a supported GitHub checkout".to_string()],
};
return Ok(result);
}
if options.fail_on_dirty && status.working_tree_dirty {
bail!(
"refusing to bootstrap dirty repo {} during clone bootstrap",
repo_root.display()
);
}
let public_remote = status
.public_remote
.clone()
.ok_or_else(|| anyhow::anyhow!("missing public remote for {}", repo_root.display()))?;
let public_default_branch = status.public_default_branch.clone().ok_or_else(|| {
anyhow::anyhow!("missing public default branch for {}", repo_root.display())
})?;
let home_branch = status.home_branch.clone();
if status.configured_home_branch.as_deref() != Some(home_branch.as_str()) {
steps.push(format!("set git config flow.homeBranch={home_branch}"));
if !options.dry_run {
git_run_in(View on GitHub (pinned to a747e741ae)
Solutions
- Commit or stash the local changes, then re-run bootstrap.
- Clean untracked junk files (`git clean` after review) so the tree is clean.
- Re-clone into a fresh directory if changes are disposable.
Example fix
// before: dirty tree, fail_on_dirty=true bootstrap(repo) // after $ git -C repo stash # or commit bootstrap(repo)
Defensive patterns
Strategy: validation
Validate before calling
fn dirty(repo: &Path) -> bool {
let out = std::process::Command::new("git")
.args(["status", "--porcelain"])
.current_dir(repo)
.output()
.expect("git status");
!out.stdout.is_empty()
}
// run bootstrap only if !dirty(repo_root) with fail_on_dirty set Try / catch
match bootstrap_clone_repo(&repo_root, &options) {
Err(e) if e.to_string().contains("refusing to bootstrap dirty repo") => {
git(&repo_root, &["stash"])?;
bootstrap_clone_repo(&repo_root, &options)?;
}
r => r?,
} Prevention
- Commit or stash local changes before running bootstrap.
- Add common junk files (.DS_Store, editor artifacts) to .gitignore.
- Run bootstrap immediately after clone, before making edits.
- Check `git status --porcelain` in CI before bootstrap steps.
When it happens
Trigger: bootstrap_clone_repo invoked on a repo whose git status shows a dirty working tree, with fail_on_dirty enabled.
Common situations: Post-clone hooks or editors created/modified files before bootstrap ran; the user resumed work in a partially-bootstrapped repo; OS junk files (.DS_Store) make the tree dirty.
Related errors
- jj git export retry loop should always return
- Lin.app is not running
- No branches available to search
- No branches matched query '{}'.
- No branches available for AI matching
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/cacde4d9fd144a01.
Report an issue: GitHub.