{"record":{"id":"6f0b2ba7b911afe9","repo":"gitbutlerapp/gitbutler","slug":"the-repository-at-has-no-git-directory-gitbut","errorCode":null,"errorMessage":"The repository at {} has no .git directory. GitButler requires a .git directory.","messagePattern":"The repository at (.+?) has no \\.git directory\\. GitButler requires a \\.git directory\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":254,"sourceCode":"            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NotADirectory => Err(anyhow::anyhow!(\n            \"The path {} is not a directory\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::BareRepository => Err(anyhow::anyhow!(\n            \"The repository at {} is bare. GitButler requires a non-bare repository.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NonMainWorktree => Err(anyhow::anyhow!(\n            \"The repository at {} is a non-main worktree. GitButler requires the main worktree.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(\n            \"The repository at {} has no working directory. GitButler requires a working directory.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NoDotGitDirectory => Err(anyhow::anyhow!(\n            \"The repository at {} has no .git directory. GitButler requires a .git directory.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(\n            \"The repository at {} uses the currently unsupported reftable reference format.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NotAGitRepository(_) => Err(anyhow::anyhow!(\n            \"The path {} is not a git repository.\",\n            repo_path.display()\n        )),\n    }?;\n\n    // A ported project can keep its target in Git config while the legacy `virtual_branches.toml`\n    // / database store is empty — for example after that store was reset. The check below would\n    // then see a target and report \"already set up\", but the workspace needs the legacy default\n    // target to work. Repair it from the workspace first so setup isn't a dead end.\n    if gitbutler_branch_actions::base::bootstrap_default_target_if_missing(&*ctx)?","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/setup.rs#L236-L272","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check for the repository marker: `ls -a /the/path` — is there a `.git`?","If this folder should be a fresh repo, run `git init` (and make an initial commit) before setup","If it is a stripped copy, re-clone from the real remote instead"],"exampleFix":"# before: plain directory, no .git\nbut setup ~/downloads/project-src\n\n# after: initialize (or re-clone) first\ncd ~/downloads/project-src && git init && git add -A && git commit -m init\nbut setup ~/downloads/project-src","handlingStrategy":"validation","validationCode":"if !repo_path.join(\".git\").exists() {\n    anyhow::bail!(\"no .git found in {repo_path:?}; run 'git init' or re-clone\");\n}","typeGuard":"fn is_no_dotgit(out: &gitbutler_project::AddProjectOutcome) -> bool {\n    matches!(out, gitbutler_project::AddProjectOutcome::NoDotGitDirectory)\n}","tryCatchPattern":"match add_project(&repo_path) {\n    Ok(out) if is_no_dotgit(&out) => { /* offer git init or re-clone */ }\n    Ok(out) => { /* other outcomes */ }\n    Err(err) if err.to_string().contains(\"no .git directory\") => { /* init guidance */ }\n    Err(err) => return Err(err),\n}","preventionTips":["Remember exported archives are not clones; re-clone from the remote","Include dot-directories when copying repositories (`rsync` without excludes)","Check `ls -a` for `.git` before pointing tools at a folder"],"tags":["rust","cli","setup","git","repository-init"],"backgroundTag":"missing-git-directory","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}