gitbutlerapp/gitbutler · error

Bare repositories are not supported.

Error message

Bare repositories are not supported.

What it means

init_ctx requires a repository with a working directory, because GitButler operates on checked-out files and workspace state. When the discovered repository is bare (repo.workdir() returns None), initialization bails with this message. Bare repos have no working tree, so GitButler mode cannot function there.

Solutions

  1. Run but from a normal (non-bare) clone of the repository that has a working tree.
  2. Clone the bare repo: `git clone /path/to/repo.git` and run `but setup` in the clone.
  3. If a bare checkout is genuinely needed, use plain git tooling instead of but.

Example fix

// before
 cd /srv/git/myproject.git && but status
// after
git clone /srv/git/myproject.git ~/myproject && cd ~/myproject && but setup
Defensive patterns

Strategy: validation

Validate before calling

# refuse to run but against a bare repo
toplevel=$(git rev-parse --gd --show-toplevel 2>/dev/null) || toplevel=$(git rev-parse --show-toplevel 2>/dev/null) || exit 1
[ -n "$toplevel" ] || { echo "Bare repo: clone it first"; exit 1; }

Prevention

When it happens

Trigger: Running a but command with the current directory inside, or pointing at, a bare git repository (e.g. created with `git init --bare` or a server-side repo like project.git).

Common situations: SSHing into a server's origin repo; accidentally setting GIT_DIR to a bare repo; cloning with --bare and then trying to use but there.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at crates/but/src/setup.rs:125

    let app_settings = crate::app_settings()?;
    // lets try to get the repo from the current directory
    let repo = match but_ctx::discover_main_repo(&args.current_dir) {
        Ok(repo) => repo,
        Err(_) => anyhow::bail!(
            "No git repository found at {}\nPlease run 'but setup' to initialize the project.",
            &args.current_dir.display()
        ),
    };

    // Check if we're on gitbutler/workspace with non-workspace commits on top
    // before creating the context
    if matches!(options.workspace_check, WorkspaceCheck::Enabled) {
        check_workspace_commits_before_init(&repo, out)?;
    }

    let (ctx, fetch_interval_minutes, last_fetch) = {
        let Some(workdir) = repo.workdir() else {
            anyhow::bail!("Bare repositories are not supported.");
        };
        #[cfg(feature = "legacy")]
        {
            use but_ctx::LegacyProject;

            use crate::command::legacy::setup::check_project_setup;

            if app_settings.feature_flags.single_branch {
                let project = match LegacyProject::find_by_worktree_dir(workdir) {
                    Ok(project) => project,
                    Err(_) => match gitbutler_project::add(workdir)? {
                        gitbutler_project::AddProjectOutcome::Added(project)
                        | gitbutler_project::AddProjectOutcome::AlreadyExists(project) => project,
                        outcome => outcome.try_project()?,
                    },
                };
                let mut ctx =
                    Context::new_from_legacy_project_and_settings(&project, app_settings.clone())?;

View on GitHub (pinned to 58e5313667)