eyaltoledano/claude-task-master · error
NO_CURRENT_BRANCH
NO_CURRENT_BRANCH
Error message
Could not determine current git branch
What it means
Returned by createTagFromBranchDirect when no targetBranch argument was supplied and the current git branch could not be determined from the repository (e.g. detached HEAD or no commits yet). The function needs a branch name to derive the tag; without one it fails with code NO_CURRENT_BRANCH.
Source
Thrown at mcp-server/src/core/direct-functions/create-tag-from-branch.js:101
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'
}
};
}
}
log.info(`Creating tag from git branch: ${targetBranch}`);
// Prepare options
const options = {
copyFromCurrent: copyFromCurrent || false,
copyFromTag,
description:
description || `Tag created from git branch "${targetBranch}"`,
autoSwitch: autoSwitch || false
};
// Call the createTagFromBranch functionView on GitHub (pinned to c0c98d367c)
Solutions
- Pass the branch explicitly in the tool call (e.g. branchName: 'main').
- Ensure HEAD is on a named branch: 'git checkout -b main' or 'git checkout main'.
- Make an initial commit so the branch exists: 'git commit --allow-empty -m init'.
- Verify with 'git -C <projectRoot> branch --show-current' that a branch name is resolvable before invoking the tool.
Example fix
// before
await createTagFromBranchDirect({ projectRoot }); // detached HEAD, no branch arg
// after
await createTagFromBranchDirect({ projectRoot, branchName: currentBranch }); // e.g. 'main' Defensive patterns
Strategy: validation
Validate before calling
const { execSync } = require('child_process');
function currentBranch(root) {
try {
return execSync('git branch --show-current', { cwd: root }).toString().trim() || null;
} catch { return null; }
}
const branch = args.branchName || currentBranch(projectRoot);
if (!branch) throw new Error('No current branch; pass branchName explicitly'); Type guard
function hasBranchName(args) {
return typeof args.branchName === 'string' && args.branchName.trim().length > 0;
} Try / catch
const res = await createTagFromBranchDirect(args);
if (!res.success && res.error?.code === 'NO_CURRENT_BRANCH') {
// fall back to asking the user for a branch, or `git checkout -b main` first
} Prevention
- Always pass the branchName argument explicitly instead of relying on current-branch inference.
- Avoid running integrations from a detached-HEAD checkout; create a named branch first.
- Ensure the repo has an initial commit before automating branch-based operations.
- Check 'git branch --show-current' output in CI before invoking the tool.
When it happens
Trigger: Calling create_tag_from_branch without the branchName/targetBranch parameter on a repo in detached HEAD state ('git checkout <sha>'), on an unborn branch (fresh 'git init' with zero commits), or where the git branch command fails in the target directory.
Common situations: CI checkouts that pin a commit SHA (GitHub Actions checkout of a tag/SHA), freshly initialized repos with no first commit, or forgetting to pass the branch argument from an MCP client that omits optional fields.
Related errors
- branch already exists: ${branchName}
- branch does not exist: ${branchName}
- cannot delete current branch: ${branchName}
- projectRoot is required for isOnDefaultBranch
- projectRoot is required for checkAndAutoSwitchGitTag
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/f3246a034cc2c92d.
Report an issue: GitHub.