gitbutlerapp/gitbutler · error

The repository at {} has no .git directory. GitButler requir

Error message

The repository at {} has no .git directory. GitButler requires a .git directory.

What it means

Raised while registering a repository: the path is a directory but contains no `.git` entry (`AddProjectOutcome::NoDotGitDirectory`). GitButler requires a `.git` directory (or worktree pointer) inside the project path; without it there is no repository to manage.

Source

Thrown at crates/but/src/command/legacy/setup.rs:254

            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::NotADirectory => Err(anyhow::anyhow!(
            "The path {} is not a directory",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::BareRepository => Err(anyhow::anyhow!(
            "The repository at {} is bare. GitButler requires a non-bare repository.",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::NonMainWorktree => Err(anyhow::anyhow!(
            "The repository at {} is a non-main worktree. GitButler requires the main worktree.",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(
            "The repository at {} has no working directory. GitButler requires a working directory.",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::NoDotGitDirectory => Err(anyhow::anyhow!(
            "The repository at {} has no .git directory. GitButler requires a .git directory.",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(
            "The repository at {} uses the currently unsupported reftable reference format.",
            repo_path.display()
        )),
        gitbutler_project::AddProjectOutcome::NotAGitRepository(_) => Err(anyhow::anyhow!(
            "The path {} is not a git repository.",
            repo_path.display()
        )),
    }?;

    // A ported project can keep its target in Git config while the legacy `virtual_branches.toml`
    // / database store is empty — for example after that store was reset. The check below would
    // then see a target and report "already set up", but the workspace needs the legacy default
    // target to work. Repair it from the workspace first so setup isn't a dead end.
    if gitbutler_branch_actions::base::bootstrap_default_target_if_missing(&*ctx)?

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Check for the repository marker: `ls -a /the/path` — is there a `.git`?
  2. If this folder should be a fresh repo, run `git init` (and make an initial commit) before setup
  3. If it is a stripped copy, re-clone from the real remote instead

Example fix

# before: plain directory, no .git
but setup ~/downloads/project-src

# after: initialize (or re-clone) first
cd ~/downloads/project-src && git init && git add -A && git commit -m init
but setup ~/downloads/project-src
Defensive patterns

Strategy: validation

Validate before calling

if !repo_path.join(".git").exists() {
    anyhow::bail!("no .git found in {repo_path:?}; run 'git init' or re-clone");
}

Type guard

fn is_no_dotgit(out: &gitbutler_project::AddProjectOutcome) -> bool {
    matches!(out, gitbutler_project::AddProjectOutcome::NoDotGitDirectory)
}

Try / catch

match add_project(&repo_path) {
    Ok(out) if is_no_dotgit(&out) => { /* offer git init or re-clone */ }
    Ok(out) => { /* other outcomes */ }
    Err(err) if err.to_string().contains("no .git directory") => { /* init guidance */ }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: Running setup in an ordinary folder that was never `git init`ed, a directory that only holds a copy of the files (e.g. exported archive, `rsync` without the `.git` dir), or where `.git` was deleted/hidden by tooling.

Common situations: Downloaded source archives (zip/tar) instead of clones; `.git` excluded by a copy or backup filter; dotfiles hidden in a file manager so users assume it's a clone.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/6f0b2ba7b911afe9. Report an issue: GitHub.