{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":262,"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":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/setup.rs#L244-L280","documentation":"Raised while registering a repository: the directory exists and has some git-looking structure, but `gitbutler_project` concluded it is not a git repository (`AddProjectOutcome::NotAGitRepository`). This is the catch-all git-detection failure after the more specific checks (missing .git, bare, worktree, reftable) did not match.","triggerScenarios":"Setup against a directory with a corrupted or foreign `.git` (truncated copy, wrong ownership/permissions so discovery fails, a `.git` file with a dangling worktree pointer), or a directory containing only nested content that is not itself a repo root.","commonSituations":"Interrupted clones or rsyncs; `.git` contents made unreadable (permission/ownership changes, safe.directory issues); tools that write their own `.git`-named files; wrong nesting level when pointing at a parent folder.","solutions":["Sanity-check with git itself: `git -C /the/path status` — whatever error it reports is the root cause","If discovery is blocked by ownership, allow it: `git config --global --add safe.directory /the/path`","If `.git` is corrupt or partial, re-clone the repository","Make sure you point at the actual repo root, not a parent or unrelated subfolder"],"exampleFix":"# before: path passes directory checks but git itself is broken\ngit -C ~/work/project status   # reports 'not a git repository' or dubious ownership\n\n# after: fix discovery, then register\ngit config --global --add safe.directory ~/work/project\nbut setup ~/work/project","handlingStrategy":"validation","validationCode":"if gix::discover(&repo_path).is_err() {\n    anyhow::bail!(\"git itself cannot open {repo_path:?}; run 'git -C {repo_path:?} status' to see why\");\n}","typeGuard":"fn is_not_a_repo(out: &gitbutler_project::AddProjectOutcome) -> bool {\n    matches!(out, gitbutler_project::AddProjectOutcome::NotAGitRepository(_))\n}","tryCatchPattern":"match add_project(&repo_path) {\n    Ok(out) if is_not_a_repo(&out) => { /* surface git's own error for the path */ }\n    Ok(out) => { /* other outcomes */ }\n    Err(err) if err.to_string().contains(\"not a git repository\") => { /* repo-repair guidance */ }\n    Err(err) => return Err(err),\n}","preventionTips":["Run `git status` in the directory first; if git is unhappy, fix that before setup","Add suspicious paths to `safe.directory` when ownership differs (containers, mounts)","Re-clone rather than repairing partially copied `.git` directories"],"tags":["rust","cli","setup","git","repo-discovery"],"backgroundTag":"not-a-git-repository","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}