{"record":{"id":"8a609a75542e9a7b","repo":"eyaltoledano/claude-task-master","slug":"not-a-git-repository-this-projectpath","errorCode":null,"errorMessage":"not a git repository: ${this.projectPath}","messagePattern":"not a git repository: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/git/adapters/git-adapter.ts","lineNumber":145,"sourceCode":"\t}\n\n\t/**\n\t * Gets the repository root path.\n\t * Works even when called from a subdirectory.\n\t *\n\t * @returns {Promise<string>} Absolute path to repository root\n\t * @throws {Error} If not in a git repository\n\t *\n\t * @example\n\t * const root = await git.getRepositoryRoot();\n\t * console.log(`Repository root: ${root}`);\n\t */\n\tasync getRepositoryRoot(): Promise<string> {\n\t\ttry {\n\t\t\tconst result = await this.git.revparse(['--show-toplevel']);\n\t\t\treturn path.normalize(result.trim());\n\t\t} catch (error) {\n\t\t\tthrow new Error(`not a git repository: ${this.projectPath}`);\n\t\t}\n\t}\n\n\t/**\n\t * Validates the repository state.\n\t * Checks for corruption and basic integrity.\n\t *\n\t * @returns {Promise<void>}\n\t * @throws {Error} If repository is corrupted or invalid\n\t *\n\t * @example\n\t * await git.validateRepository();\n\t * console.log('Repository is valid');\n\t */\n\tasync validateRepository(): Promise<void> {\n\t\t// Check if it's a git repository\n\t\tconst isRepo = await this.isGitRepository();\n\t\tif (!isRepo) {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/git/adapters/git-adapter.ts#L127-L163","documentation":"Plain Error thrown by GitAdapter.getRepositoryRoot when `git rev-parse --show-toplevel` fails for the adapter's projectPath — normally because the directory is not inside a git working tree (also fired for other rev-parse failures, whose original message is discarded). The project path is interpolated into the message.","triggerScenarios":"Calling getRepositoryRoot() when projectPath is outside any repository; the .git directory was deleted; the repo is bare (rev-parse --show-toplevel fails on bare repos); git init was never run; path case/typo points to a sibling non-repo directory.","commonSituations":"Freshly cloned-then-stripped projects; temp directories created without git init; CI checkouts using export without git metadata; running the tool one directory above/below where .git actually lives; detached/corrupt .git.","solutions":["Run `git init` in projectPath if it should be a repository, or use the correct directory that already contains .git","Verify with `git -C <projectPath> rev-parse --show-toplevel` to reproduce outside the library","Call isGitRepository() first and branch your logic instead of relying on getRepositoryRoot throwing","Check for a bare repo — --show-toplevel fails there; use git rev-parse --git-dir semantics instead","Confirm no typo/case mismatch in projectPath and that .git still exists"],"exampleFix":"// before\nconst root = await git.getRepositoryRoot(); // throws if not a repo\n// after\nif (await git.isGitRepository()) {\n  const root = await git.getRepositoryRoot();\n} else {\n  await git.ensureGitRepository(); // or init manually\n  const root = await git.getRepositoryRoot();\n}","handlingStrategy":"validation","validationCode":"import { execFileSync } from 'child_process';\ntry {\n  execFileSync('git', ['-C', projectPath, 'rev-parse', '--show-toplevel'], { stdio: 'pipe' });\n} catch {\n  throw new Error(`${projectPath} is not inside a git worktree`);\n}","typeGuard":"function isGitWorktree(dir: string): boolean {\n  try {\n    execFileSync('git', ['-C', dir, 'rev-parse', '--is-inside-work-tree'], { stdio: 'pipe' });\n    return true;\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  const root = await git.getRepositoryRoot();\n} catch (e) {\n  if (String(e.message).startsWith('not a git repository')) {\n    await git.ensureGitRepository(); // init + commit scaffolding\n    const root = await git.getRepositoryRoot();\n  } else throw e;\n}","preventionTips":["Call isGitRepository() before getRepositoryRoot() in flows that may see non-repos","Run `git init` as part of project scaffolding","Preserve .git when copying/exporting projects (rsync dotfiles, avoid git archive for working copies)","Point the adapter at the repo root or a subdirectory of it, not a sibling directory"],"tags":["git","repository","validation","worktree"],"backgroundTag":"not-a-git-repository","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}