eyaltoledano/claude-task-master · error

NOT_GIT_REPO

NOT_GIT_REPO

Error message

Not in a git repository. Cannot use fromBranch option.

What it means

When add_tag is called with fromBranch, the function verifies the project root is inside a git work tree using gitUtils.isGitRepository before attempting to read branch info. If git says the directory is not a repository, creation of a tag from a branch is impossible and this structured NOT_GIT_REPO error is returned.

Source

Thrown at mcp-server/src/core/direct-functions/add-tag.js:80

		}

		// Handle --from-branch option
		if (fromBranch) {
			log.info('Creating tag from current git branch');

			// Import git utilities
			const gitUtils = await import(
				'../../../../scripts/modules/utils/git-utils.js'
			);

			// Check if we're in a git repository
			if (!(await gitUtils.isGitRepository(projectRoot))) {
				log.error('Not in a git repository');
				disableSilentMode();
				return {
					success: false,
					error: {
						code: 'NOT_GIT_REPO',
						message: 'Not in a git repository. Cannot use fromBranch option.'
					}
				};
			}

			// Get current git branch
			const currentBranch = await gitUtils.getCurrentBranch(projectRoot);
			if (!currentBranch) {
				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

  1. Run 'git init' in the project root
  2. Set projectRoot to the directory containing .git
  3. Drop the fromBranch option and create the tag from the current tasks file instead

Example fix

// before
add_tag({ tasksJsonPath: path, fromBranch: true });
// after
git init && add_tag({ tasksJsonPath: path, fromBranch: true });
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'child_process';
function isGitRepo(root) {
  try { execSync('git rev-parse --is-inside-work-tree', { cwd: root, stdio: 'ignore' }); return true; }
  catch { return false; }
}
if (args.fromBranch && !isGitRepo(projectRoot)) { /* fall back to non-branch tag creation */ }

Type guard

function canUseFromBranch(args, root) {
  return typeof args?.fromBranch === 'boolean' && args.fromBranch && isGitRepo(root);
}

Try / catch

const res = await addTagDirect(args);
if (!res.success && res.error?.code === 'NOT_GIT_REPO') {
  // retry without fromBranch or instruct user to git init
}

Prevention

When it happens

Trigger: Calling add_tag with fromBranch: true (or a fromBranch branch name) while projectRoot is not a git repository or git metadata is unavailable.

Common situations: Project copied without the .git directory; running the MCP server from a subdirectory outside the repo; projectRoot misconfigured to a non-repo path; fresh project where git init was never run.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/d495c5b4b41dab43. Report an issue: GitHub.