{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":273,"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":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/setup.rs#L255-L291","documentation":"Thrown when `AddProjectOutcome::NoDotGitDirectory` is returned. The path looks like a candidate repository but no `.git` directory (or file for worktrees/submodules) was found, so GitButler cannot locate the git metadata.","triggerScenarios":"Running setup on a plain directory that is not a repo, or a directory where `.git` was deleted, or a downloaded source archive (no git metadata).","commonSituations":"Extracting a zip/tarball of a project and trying to register it; `.git` removed by cleanup scripts; initializing a folder without `git init`.","solutions":["Verify the repo with `git -C <path> status`; if it fails, run `git init` or clone the project.","Restore the deleted `.git` directory (re-clone and copy, or re-clone entirely).","Point setup at the actual repository root, not a subfolder outside it."],"exampleFix":"// before\nbut setup ~/downloads/myrepo-1.0\n// after\ngit clone <url> ~/code/myrepo\nbut setup ~/code/myrepo","handlingStrategy":"validation","validationCode":"if (!fs.existsSync(path.join(repoPath, '.git'))) {\n  throw new Error(`${repoPath} has no .git; run git init or clone first`);\n}","typeGuard":"function hasGitDir(p: string): boolean {\n  try { return fs.existsSync(path.join(p, '.git')); } catch { return false; }\n}","tryCatchPattern":"try {\n  await run(['but', 'setup', repoPath]);\n} catch (e) {\n  if (String(e).includes('no .git directory')) {\n    console.error('This is not a git checkout; clone or git init first.');\n  }\n  throw e;\n}","preventionTips":["Never delete .git to 'reset' a repo; re-clone instead.","Don't register extracted source archives; clone from the remote.","Confirm with `git status` before onboarding a folder."],"tags":["git","filesystem","cli","setup"],"backgroundTag":"directory-not-found","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"}