{"record":{"id":"7a9f4c1490165f55","repo":"gitbutlerapp/gitbutler","slug":"bare-repositories-are-not-supported","errorCode":null,"errorMessage":"Bare repositories are not supported.","messagePattern":"Bare repositories are not supported\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/setup.rs","lineNumber":125,"sourceCode":"    let app_settings = crate::app_settings()?;\n    // lets try to get the repo from the current directory\n    let repo = match but_ctx::discover_main_repo(&args.current_dir) {\n        Ok(repo) => repo,\n        Err(_) => anyhow::bail!(\n            \"No git repository found at {}\\nPlease run 'but setup' to initialize the project.\",\n            &args.current_dir.display()\n        ),\n    };\n\n    // Check if we're on gitbutler/workspace with non-workspace commits on top\n    // before creating the context\n    if matches!(options.workspace_check, WorkspaceCheck::Enabled) {\n        check_workspace_commits_before_init(&repo, out)?;\n    }\n\n    let (ctx, fetch_interval_minutes, last_fetch) = {\n        let Some(workdir) = repo.workdir() else {\n            anyhow::bail!(\"Bare repositories are not supported.\");\n        };\n        #[cfg(feature = \"legacy\")]\n        {\n            use but_ctx::LegacyProject;\n\n            use crate::command::legacy::setup::check_project_setup;\n\n            if app_settings.feature_flags.single_branch {\n                let project = match LegacyProject::find_by_worktree_dir(workdir) {\n                    Ok(project) => project,\n                    Err(_) => match gitbutler_project::add(workdir)? {\n                        gitbutler_project::AddProjectOutcome::Added(project)\n                        | gitbutler_project::AddProjectOutcome::AlreadyExists(project) => project,\n                        outcome => outcome.try_project()?,\n                    },\n                };\n                let mut ctx =\n                    Context::new_from_legacy_project_and_settings(&project, app_settings.clone())?;","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/setup.rs#L107-L143","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run but from a normal (non-bare) clone of the repository that has a working tree.","Clone the bare repo: `git clone /path/to/repo.git` and run `but setup` in the clone.","If a bare checkout is genuinely needed, use plain git tooling instead of but."],"exampleFix":"// before\n cd /srv/git/myproject.git && but status\n// after\ngit clone /srv/git/myproject.git ~/myproject && cd ~/myproject && but setup","handlingStrategy":"validation","validationCode":"# refuse to run but against a bare repo\ntoplevel=$(git rev-parse --gd --show-toplevel 2>/dev/null) || toplevel=$(git rev-parse --show-toplevel 2>/dev/null) || exit 1\n[ -n \"$toplevel\" ] || { echo \"Bare repo: clone it first\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `git rev-parse --is-bare-repository` before but commands","Only operate on working clones, never server-side repos","Clone bare repos before using GitButler"],"tags":["git","bare-repository","unsupported-operation","cli"],"backgroundTag":"unsupported-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}