eyaltoledano/claude-task-master · error
not a git repository: ${this.projectPath} Please run this co
Error message
not a git repository: ${this.projectPath}
Please run this command from within a git repository, or initialize one with 'git init'. What it means
ensureGitRepository() checks isGitRepository() and throws when the configured projectPath is not inside a git working tree. It is a guard used by execute() and startWorkflow() so git operations never run against a non-repo directory. The message includes the offending path and suggests running 'git init'.
Source
Thrown at packages/tm-core/src/modules/git/adapters/git-adapter.ts:191
throw new Error(`Repository validation failed: ${errorMessage}`);
}
}
/**
* Ensures we're in a valid git repository before performing operations.
* Convenience method that throws descriptive errors.
*
* @returns {Promise<void>}
* @throws {Error} If not in a valid git repository
*
* @example
* await git.ensureGitRepository();
* // Safe to perform git operations after this
*/
async ensureGitRepository(): Promise<void> {
const isRepo = await this.isGitRepository();
if (!isRepo) {
throw new Error(
`not a git repository: ${this.projectPath}\n` +
`Please run this command from within a git repository, or initialize one with 'git init'.`
);
}
}
/**
* Checks if the working tree is clean (no uncommitted changes).
* A clean working tree has no staged, unstaged, or untracked files.
*
* @returns {Promise<boolean>} True if working tree is clean
*
* @example
* const isClean = await git.isWorkingTreeClean();
* if (!isClean) {
* console.log('Working tree has uncommitted changes');
* }
*/View on GitHub (pinned to c0c98d367c)
Solutions
- cd into a directory inside your git repository before running the command.
- Initialize a repo if intended: git init && git add -A && git commit -m 'initial'.
- Verify the adapter's projectPath option points at the repo root, not an unrelated folder.
- In CI, use a real git checkout (actions/checkout, git clone) instead of artifact downloads.
Example fix
// before npx tm start-workflow # run in ~/new-project (no .git) // after cd ~/my-git-project && git init 2>/dev/null; npx tm start-workflow
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
import path from 'path';
function looksLikeGitRepo(dir: string): boolean {
let d = path.resolve(dir);
while (true) {
if (existsSync(path.join(d, '.git'))) return true;
const parent = path.dirname(d);
if (parent === d) return false;
d = parent;
}
} Try / catch
try {
await git.ensureGitRepository();
} catch (e) {
if (e instanceof Error && e.message.startsWith('not a git repository')) {
console.error(`Initialize a repo first: cd ${process.cwd()} && git init`);
process.exitCode = 1;
return;
}
throw e;
} Prevention
- Always resolve projectPath to a directory containing .git before constructing the adapter.
- Call ensureGitRepository() early in CLI entrypoints, before any work is done.
- In CI, use real git checkouts, not archive/tarball artifacts.
- Document in onboarding that commands must run from inside a repo.
When it happens
Trigger: Calling execute() or startWorkflow(), or ensureGitRepository() directly, when this.projectPath has no .git directory (or is not under one), e.g. wrong projectPath passed to the adapter or running the CLI outside a repo.
Common situations: Running a taskmaster command from a freshly created project folder; projectPath pointing at a subdirectory of a non-repo; CI checkout using archive/tarball downloads instead of git clone (no .git).
Related errors
- not a git repository: ${this.projectPath}
- NOT_GIT_REPOSITORY
- Tag "${tagName}" for branch "${currentBranch}" does not exis
- Failed to fetch tasks from any tag. First error: ${failedTag
- ${authCheck.error}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/3050dbccd2bcff3f.
Report an issue: GitHub.