{"record":{"id":"bc28f917dac6db63","repo":"gitbutlerapp/gitbutler","slug":"no-git-directory-found-in-repository","errorCode":null,"errorMessage":"no .git directory found in repository","messagePattern":"no \\.git directory found in repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-project/src/project.rs","lineNumber":331,"sourceCode":"\n    /// Try to get the `Project`, returning an error if it was not added.\n    pub fn try_project(self) -> anyhow::Result<Project> {\n        match self {\n            AddProjectOutcome::Added(p) => Ok(p),\n            AddProjectOutcome::AlreadyExists(_) => Err(anyhow::anyhow!(\"project already exists\")),\n            AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!(\"project path not found\")),\n            AddProjectOutcome::NotADirectory => {\n                Err(anyhow::anyhow!(\"project path is not a directory\"))\n            }\n            AddProjectOutcome::BareRepository => {\n                Err(anyhow::anyhow!(\"bare repositories are not supported\"))\n            }\n            AddProjectOutcome::NonMainWorktree => {\n                Err(anyhow::anyhow!(\"non-main worktrees are not supported\"))\n            }\n            AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(\"no workdir found for repository\")),\n            AddProjectOutcome::NoDotGitDirectory => {\n                Err(anyhow::anyhow!(\"no .git directory found in repository\"))\n            }\n            AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(\n                \"unsupported repository reference format: reftable\"\n            )),\n            AddProjectOutcome::NotAGitRepository(msg) => {\n                Err(anyhow::anyhow!(\"not a git repository: {msg}\"))\n            }\n        }\n    }\n}\n","sourceCodeStart":313,"sourceCodeEnd":342,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/gitbutler-project/src/project.rs#L313-L342","documentation":"AddProjectOutcome::NoDotGitDirectory mapped through try_project: the path is a directory but no .git entry (directory or gitdir-pointer file) could be found for it, so it cannot be treated as a git repository. This fires before the finer 'not a git repository' classification when the .git discovery itself comes up empty.","triggerScenarios":"add_project on a plain folder never used with git; a directory whose .git was deleted or renamed; subdirectories of a repo passed without discovery from the root; .dotfile filtering/hidden-file settings hiding .git from discovery.","commonSituations":"Selecting a random project folder or an extracted tarball without .git; users who deleted .git to 'reset' the repo; picking a subfolder while expecting automatic upward discovery.","solutions":["Run `git init` (or clone) so a .git exists, then add the project","Pass the repository root that actually contains .git, not a subdirectory","If .git was accidentally removed, restore it (backup, or re-clone and copy work over) before onboarding"],"exampleFix":"// before\nlet project = add_project(&path, ...).try_project()?; // no .git -> rejected\n\n// after: require a .git entry before adding\nif !path.join(\".git\").exists() {\n    anyhow::bail!(\"no .git at {} — run `git init` or pass the repository root\", path.display());\n}\nlet project = add_project(&path, ...).try_project()?;","handlingStrategy":"validation","validationCode":"if !path.join(\".git\").exists() {\n    anyhow::bail!(\"no .git at {} — run `git init` or pass the repository root\", path.display());\n}\nlet project = add_project(&path, ...).try_project()?;","typeGuard":"fn looks_like_git_repo_root(p: &Path) -> bool {\n    p.join(\".git\").exists() // directory (normal) or gitdir: file (worktree)\n}","tryCatchPattern":"match add_project(&path, ...) {\n    AddProjectOutcome::NoDotGitDirectory => prompt_to_init_or_clone(&path),\n    outcome => outcome.try_project(),\n}","preventionTips":["Require a .git entry before add_project","Pass the repository root, not a subfolder that happens to be inside a repo","If users select subfolders, walk upward to find the containing .git before adding"],"tags":["gitbutler","project","git","filesystem","validation"],"backgroundTag":"dotgit-directory-missing","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}