gitbutlerapp/gitbutler · error

bare repositories are not supported

Error message

bare repositories are not supported

What it means

try_project maps AddProjectOutcome::BareRepository to this error. The path points to a bare git repository (one without a working tree), which GitButler cannot manage because its virtual-branch model requires a checked-out working directory.

Solutions

  1. Clone the bare repo to a working clone (`git clone <path>.git`) and add the clone instead.
  2. If you have an existing bare repo, create a non-bare working copy: `git clone --no-hardlinks <bare-path> <workdir>`.
  3. Detect bare repos up front (`git rev-parse --is-bare-repository`) and skip adding them.

Example fix

// before
let project = add_project(server_repo_path)?.try_project()?;
// after
let output = Command::new("git")
    .args(["rev-parse", "--is-bare-repository"])
    .current_dir(&server_repo_path)
    .output()?;
if output.stdout == b"true\n" {
    return Err("add a working clone, not a bare repository".into());
}
let project = add_project(server_repo_path)?.try_project()?;
Defensive patterns

Strategy: validation

Validate before calling

let out = std::process::Command::new("git")
    .args(["rev-parse", "--is-bare-repository"])
    .current_dir(path)
    .output()?;
let is_bare = out.stdout == b"true\n";
if is_bare { return Err("bare repositories are not supported".into()); }

Try / catch

match outcome.try_project() {
    Err(e) if e.to_string() == "bare repositories are not supported" => {
        // offer to clone the bare repo into a working copy first
        offer_clone_flow(&path)?;
    }
    other => other,
}

Prevention

When it happens

Trigger: Adding a bare repo directory — one created with `git init --bare` or `git clone --bare`, typically recognizable by containing HEAD/objects/refs directly instead of a `.git` subdirectory.

Common situations: Pointing GitButler at a server-side repo directory (e.g. `/srv/git/project.git`), a mirror clone, or a shared bare repo used for push/pull.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/8a2a99927f2ea7d8. Report an issue: GitHub.

Appendix: source

Thrown at crates/gitbutler-project/src/project.rs:324

    /// Panics if it was not.
    pub fn unwrap_project(self) -> Project {
        match self {
            AddProjectOutcome::Added(p) => p,
            _ => panic!("called `AddProjectOutcome::unwrap_project()` on a non-project outcome"),
        }
    }

    /// Try to get the `Project`, returning an error if it was not added.
    pub fn try_project(self) -> anyhow::Result<Project> {
        match self {
            AddProjectOutcome::Added(p) => Ok(p),
            AddProjectOutcome::AlreadyExists(_) => Err(anyhow::anyhow!("project already exists")),
            AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!("project path not found")),
            AddProjectOutcome::NotADirectory => {
                Err(anyhow::anyhow!("project path is not a directory"))
            }
            AddProjectOutcome::BareRepository => {
                Err(anyhow::anyhow!("bare repositories are not supported"))
            }
            AddProjectOutcome::NonMainWorktree => {
                Err(anyhow::anyhow!("non-main worktrees are not supported"))
            }
            AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!("no workdir found for repository")),
            AddProjectOutcome::NoDotGitDirectory => {
                Err(anyhow::anyhow!("no .git directory found in repository"))
            }
            AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(
                "unsupported repository reference format: reftable"
            )),
            AddProjectOutcome::NotAGitRepository(msg) => {
                Err(anyhow::anyhow!("not a git repository: {msg}"))
            }
        }
    }
}

View on GitHub (pinned to 58e5313667)