{"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 gix::discover(&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/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/setup.rs#L107-L143","documentation":"After successful repo discovery, init_ctx requires a worktree: `repo.workdir()` must return Some. Bare repositories (git init --bare) have no working directory, so GitButler has no files to manage and initialization stops immediately with this message.","triggerScenarios":"Running any but command inside a bare repository - `git init --bare`, server-side mirrors, or the popular bare-dotfiles setup (a bare repo whose worktree is $HOME via config).","commonSituations":"Bare dotfiles repos managed through a shell alias, administering gitolite/forge mirrors, cloning with --bare out of habit.","solutions":["Use a normal (non-bare) clone of the repository","For bare repos, create and cd into a linked worktree: git worktree add ../main","For bare-dotfiles setups, run but from a linked worktree, not the bare directory"],"exampleFix":"$ cd ~/repos/dotfiles.git && but branch list   # bare -> fails\n$ git -C ~/repos/dotfiles.git worktree add ~/dotfiles-main\n$ cd ~/dotfiles-main && but branch list","handlingStrategy":"validation","validationCode":"if let Ok(repo) = gix::discover(&cwd) {\n    if repo.workdir().is_none() {\n        // bare repo: refuse before invoking but, suggest a worktree\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `git rev-parse --is-bare-repository` (or repo.workdir().is_none()) first","For bare repos, create a linked worktree and run tools there","Flag bare-dotfiles setups in onboarding docs so users know but cannot run there"],"tags":["git","bare-repo","worktree","context"],"backgroundTag":"bare-repository-unsupported","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}