{"record":{"id":"1bf9c2c77b11e126","repo":"gitbutlerapp/gitbutler","slug":"the-path-is-not-a-git-repository","errorCode":null,"errorMessage":"The path {} is not a git repository.","messagePattern":"The path (.+?) is not a git repository\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":281,"sourceCode":"            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)?\n        && let Some(out) = out.for_human()\n    {\n        writeln!(\n            out,\n            \"  {}\",\n            t.success.paint(\"✓ Repaired missing target metadata\")\n        )?;\n    }","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/setup.rs#L263-L299","documentation":"Thrown when `AddProjectOutcome::NotAGitRepository(_)` is returned. After all other checks, the path was determined not to be a git repository; the wrapped inner error carries git's own diagnostic. This is the terminal fallback of the AddProjectOutcome match in setup.","triggerScenarios":"Running `but setup` on a non-repo directory (no `.git`, not detected by gix), or a corrupted `.git` that fails to open.","commonSituations":"Wrong directory selected in setup; empty newly created folder; `.git` corrupted by interrupted operations or disk issues.","solutions":["Run `git -C <path> status` to confirm git itself recognizes the repo.","If not a repo, either `git init` (new project) or clone the correct URL.","If `.git` is corrupted, re-clone the repository from the remote."],"exampleFix":"// before\nbut setup ~/empty-folder\n// after\ngit init ~/empty-folder  # or clone the repo\nbut setup ~/empty-folder","handlingStrategy":"validation","validationCode":"const st = cp.spawnSync('git', ['-C', repoPath, 'status', '--porcelain']);\nif (st.status !== 0) {\n  throw new Error(`${repoPath} is not a valid git repository: ${st.stderr}`);\n}","typeGuard":"function isGitRepo(p: string): boolean {\n  return cp.spawnSync('git', ['-C', p, 'rev-parse', '--git-dir']).status === 0;\n}","tryCatchPattern":"try {\n  await run(['but', 'setup', repoPath]);\n} catch (e) {\n  if (String(e).includes('is not a git repository')) {\n    console.error('git init or clone the project before running but setup.');\n  }\n  throw e;\n}","preventionTips":["Run `git status` as a preflight in scripts wrapping but setup.","Verify you are in the right directory before onboarding.","If git commands fail with corruption errors, re-clone before setup."],"tags":["git","cli","not-a-repository","setup"],"backgroundTag":"resource-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"}