{"record":{"id":"ebe5de942955d94a","repo":"paperclipai/paperclip","slug":"current-directory-is-not-inside-a-git-repository","errorCode":null,"errorMessage":"Current directory is not inside a git repository.","messagePattern":"Current directory is not inside a git repository\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":698,"sourceCode":"    execFileSync(\"git\", [\"check-ref-format\", \"--branch\", value], {\n      cwd,\n      stdio: [\"ignore\", \"pipe\", \"pipe\"],\n    });\n  } catch (error) {\n    throw new Error(`Invalid branch name \"${branchName}\": ${extractExecSyncErrorMessage(error) ?? String(error)}`);\n  }\n  return value;\n}\n\nfunction isPrimaryGitWorktree(cwd: string): boolean {\n  const workspace = detectGitWorkspaceInfo(cwd);\n  return Boolean(workspace && workspace.gitDir === workspace.commonDir);\n}\n\nfunction resolvePrimaryGitRepoRoot(cwd: string): string {\n  const workspace = detectGitWorkspaceInfo(cwd);\n  if (!workspace) {\n    throw new Error(\"Current directory is not inside a git repository.\");\n  }\n  if (workspace.gitDir === workspace.commonDir) {\n    return workspace.root;\n  }\n  return path.resolve(workspace.commonDir, \"..\");\n}\n\nfunction resolveRepairWorktreeDirName(branchName: string): string {\n  const normalized = branchName.trim()\n    .replace(/[^A-Za-z0-9._-]+/g, \"-\")\n    .replace(/-+/g, \"-\")\n    .replace(/^[-._]+|[-._]+$/g, \"\");\n  return normalized || \"worktree\";\n}\n\nfunction copyDirectoryContents(sourceDir: string, targetDir: string): boolean {\n  if (!existsSync(sourceDir)) return false;\n","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L680-L716","documentation":"Environment guard in git workspace detection: running `git rev-parse`-style discovery from the current directory found no enclosing git repository, so worktree operations that need a repo root (repair, make) cannot proceed.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:649 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the command from inside a git repository checkout."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}