paperclipai/paperclip · error
Current directory is not inside a git repository.
Error message
Current directory is not inside a git repository.
What it means
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.
Solutions
- Run the command from inside a git repository checkout.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cli/src/commands/worktree.ts:649 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-08-18).
Data as JSON: /api/errors/ebe5de942955d94a.
Report an issue: GitHub.
Appendix: source
Thrown at cli/src/commands/worktree.ts:698
execFileSync("git", ["check-ref-format", "--branch", value], {
cwd,
stdio: ["ignore", "pipe", "pipe"],
});
} catch (error) {
throw new Error(`Invalid branch name "${branchName}": ${extractExecSyncErrorMessage(error) ?? String(error)}`);
}
return value;
}
function isPrimaryGitWorktree(cwd: string): boolean {
const workspace = detectGitWorkspaceInfo(cwd);
return Boolean(workspace && workspace.gitDir === workspace.commonDir);
}
function resolvePrimaryGitRepoRoot(cwd: string): string {
const workspace = detectGitWorkspaceInfo(cwd);
if (!workspace) {
throw new Error("Current directory is not inside a git repository.");
}
if (workspace.gitDir === workspace.commonDir) {
return workspace.root;
}
return path.resolve(workspace.commonDir, "..");
}
function resolveRepairWorktreeDirName(branchName: string): string {
const normalized = branchName.trim()
.replace(/[^A-Za-z0-9._-]+/g, "-")
.replace(/-+/g, "-")
.replace(/^[-._]+|[-._]+$/g, "");
return normalized || "worktree";
}
function copyDirectoryContents(sourceDir: string, targetDir: string): boolean {
if (!existsSync(sourceDir)) return false;
View on GitHub (pinned to 01ad858492)