eyaltoledano/claude-task-master · error
NOT_GIT_REPOSITORY
NOT_GIT_REPOSITORY
Error message
Not in a git repository. Cannot create tag from branch.
What it means
This error is returned by the create-tag-from-branch MCP direct function when the provided projectRoot is not inside a git working tree. Creating a tag from the current branch requires git metadata (current branch, commits), so the function pre-checks with isGitRepository() and refuses to run. It is a structured {success:false,error:{code:'NOT_GIT_REPOSITORY'}} response, not a thrown exception.
Source
Thrown at mcp-server/src/core/direct-functions/create-tag-from-branch.js:85
log.error('createTagFromBranchDirect called without projectRoot');
disableSilentMode();
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'projectRoot is required'
}
};
}
// Check if we're in a git repository
if (!(await isGitRepository(projectRoot))) {
log.error('Not in a git repository');
disableSilentMode();
return {
success: false,
error: {
code: 'NOT_GIT_REPOSITORY',
message: 'Not in a git repository. Cannot create tag from branch.'
}
};
}
// Determine branch name
let targetBranch = branchName;
if (!targetBranch) {
targetBranch = await getCurrentBranch(projectRoot);
if (!targetBranch) {
log.error('Could not determine current git branch');
disableSilentMode();
return {
success: false,
error: {
code: 'NO_CURRENT_BRANCH',
message: 'Could not determine current git branch'
}View on GitHub (pinned to c0c98d367c)
Solutions
- Initialize a git repository in projectRoot: run 'git init' (and an initial commit).
- Verify projectRoot points at the directory containing .git; correct the projectRoot argument passed to the MCP tool.
- Run 'git -C <projectRoot> rev-parse --is-inside-work-tree' to confirm git recognizes the path.
- If running in Docker/CI, mount the full repository including the .git directory instead of an exported copy.
Example fix
// before
await createTagFromBranchDirect({ projectRoot: '/tmp/workspace' });
// after
// ensure /tmp/workspace is a repo:
// cd /tmp/workspace && git init && git add . && git commit -m init
await createTagFromBranchDirect({ projectRoot: '/tmp/my-git-repo' }); Defensive patterns
Strategy: validation
Validate before calling
const { execSync } = require('child_process');
function isGitRepo(root) {
try {
execSync('git rev-parse --is-inside-work-tree', { cwd: root, stdio: 'ignore' });
return true;
} catch { return false; }
}
if (!isGitRepo(projectRoot)) throw new Error(`${projectRoot} is not a git repository`); Type guard
function isGitRepoResult(r) {
return r !== null && typeof r === 'object' && r.success === true;
} Try / catch
const res = await createTagFromBranchDirect(args);
if (!res.success && res.error?.code === 'NOT_GIT_REPOSITORY') {
// surface guidance: run `git init` or fix projectRoot
} Prevention
- Always resolve projectRoot to the directory containing .git, not an arbitrary cwd.
- Run 'git rev-parse --is-inside-work-tree' in deployment checks before enabling tag tools.
- In containers, mount the whole repo including .git.
- Clone repos with git, never from ZIP archives, in CI environments.
When it happens
Trigger: Calling the create_tag_from_branch MCP tool with a projectRoot that is a plain directory, a path outside any .git tree, or a path where git init was never run. Also occurs when projectRoot points to a subdirectory resolved incorrectly or a container path lacking the mounted .git directory.
Common situations: Running the MCP server with a default working directory that is not the repo; passing an absolute path that was gitignored or volume-mounted without .git; pointing projectRoot at the parent folder above the repository; freshly cloned projects where .git was removed by an archive download (ZIP instead of git clone).
Related errors
- Failed to fetch tasks from any tag. First error: ${failedTag
- ${authCheck.error}
- Project path is required
- Project path must be an absolute path
- not a git repository: ${this.projectPath}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/cbc1445fe9929d6b.
Report an issue: GitHub.