eyaltoledano/claude-task-master · error

currently on default branch: ${currentBranch} Please create

Error message

currently on default branch: ${currentBranch}
Please create a feature branch before proceeding.

What it means

GitAdapter.ensureNotOnDefaultBranch throws this when the repository's current branch is the default branch (main/master). It is a guard used before git write operations that must not target the default branch. The thrown Error message embeds the actual current branch name and instructs the user to create a feature branch.

Source

Thrown at packages/tm-core/src/modules/git/adapters/git-adapter.ts:745

		return await this.isDefaultBranch(currentBranch);
	}

	/**
	 * Ensures the current branch is not a default branch.
	 * Throws an error if on a default branch.
	 *
	 * @returns {Promise<void>}
	 * @throws {Error} If currently on a default branch
	 *
	 * @example
	 * await git.ensureNotOnDefaultBranch();
	 * // Safe to perform operations that shouldn't happen on default branches
	 */
	async ensureNotOnDefaultBranch(): Promise<void> {
		const onDefault = await this.isOnDefaultBranch();
		if (onDefault) {
			const currentBranch = await this.getCurrentBranch();
			throw new Error(
				`currently on default branch: ${currentBranch}\n` +
					`Please create a feature branch before proceeding.`
			);
		}
	}

	/**
	 * Checks if the repository has any remotes configured.
	 *
	 * @returns {Promise<boolean>} True if remotes exist
	 *
	 * @example
	 * const hasRemote = await git.hasRemote();
	 * if (!hasRemote) {
	 *   console.log('No remotes configured');
	 * }
	 */
	async hasRemote(): Promise<boolean> {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Create and switch to a feature branch: git checkout -b feature/my-changes
  2. Re-run the operation from the new branch
  3. If operating on the default branch is intentional, bypass/adjust the guard rather than suppressing the error

Example fix

// before
await gitAdapter.commitChanges(); // throws on main
// after
await gitAdapter.createBranch('feature/my-changes');
await gitAdapter.checkoutBranch('feature/my-changes');
await gitAdapter.commitChanges();
Defensive patterns

Strategy: validation

Validate before calling

if (await gitAdapter.isOnDefaultBranch()) {
  throw new Error(`Create a feature branch first (currently on ${await gitAdapter.getCurrentBranch()})`);
}

Type guard

null

Try / catch

try {
  await gitAdapter.ensureNotOnDefaultBranch();
} catch (e) {
  if ((e as Error).message.includes('currently on default branch')) {
    // prompt user to create a feature branch
  }
}

Prevention

When it happens

Trigger: Calling any API that invokes ensureNotOnDefaultBranch() (e.g. commit/push workflows) while the repo HEAD is on 'main' or 'master', as detected by isOnDefaultBranch().

Common situations: Fresh clone (checked out on main by default), forgetting to run 'git checkout -b feature/x' before starting work, automation scripts operating directly on the default branch, or a repo whose default branch config changed.

Related errors


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