eyaltoledano/claude-task-master · error

NO_CURRENT_BRANCH

NO_CURRENT_BRANCH

Error message

Could not determine current git branch.

What it means

With the fromBranch option, addTagDirect reads the current branch via git (e.g. rev-parse --abbrev-ref HEAD). If git returns an empty value (detached HEAD with no resolvable name, or a command failure) the function returns NO_CURRENT_BRANCH because it cannot derive the new tag name from the branch.

Source

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

				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.'
					}
				};
			}

			// Prepare options for branch-based tag creation
			const branchOptions = {
				copyFromCurrent,
				copyFromTag,
				description:
					description || `Tag created from git branch "${currentBranch}"`
			};

			// Call the createTagFromBranch function
			const result = await createTagFromBranch(
				tasksJsonPath,
				currentBranch,
				branchOptions,

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Checkout a real branch first: 'git checkout -b feature-branch'
  2. Create the tag explicitly with a name instead of using fromBranch
  3. Verify 'git rev-parse --abbrev-ref HEAD' returns a branch name in the project root

Example fix

// before
add_tag({ tasksJsonPath: path, fromBranch: true }); // detached HEAD
// after
git checkout -b my-feature; add_tag({ tasksJsonPath: path, fromBranch: true });
Defensive patterns

Strategy: fallback

Validate before calling

const { execSync } = require('child_process');
function currentBranch(root) {
  try { return execSync('git rev-parse --abbrev-ref HEAD', { cwd: root }).toString().trim() || null; }
  catch { return null; }
}
if (args.fromBranch && !currentBranch(projectRoot)) { /* detached HEAD: pick explicit tag name */ }

Type guard

function branchAvailable(args, root) {
  const b = args?.fromBranch ? currentBranch(root) : 'n/a';
  return !args?.fromBranch || (typeof b === 'string' && b.length > 0 && b !== 'HEAD');
}

Try / catch

const res = await addTagDirect(args);
if (!res.success && res.error?.code === 'NO_CURRENT_BRANCH') {
  // fall back to explicit name: addTagDirect({ ...args, fromBranch: false, name: 'my-tag' })
}

Prevention

When it happens

Trigger: add_tag with fromBranch: true in a detached HEAD state, a bare repository, or when the git branch command fails/returns empty output.

Common situations: CI checkout of a specific commit SHA (detached HEAD); rebase in progress; repository with no commits yet; corrupted git state.

Related errors


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