paperclipai/paperclip · error

Invalid branch name

Error message

Invalid branch name "${branchName}": ${extractExecSyncErrorMessage(error) ?? String(error)}

What it means

Delegated format check on git branch names: the value failed `git check-ref-format --branch`, meaning git itself considers it an invalid branch reference (bad characters, double dots, leading dash, etc.); the underlying git error is embedded in the message.

Solutions

  1. Fix the branch name per git's naming rules (no spaces, no '..', no leading dash, etc.).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/worktree.ts:636 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-08-18). Data as JSON: /api/errors/49e00664f3996d6b. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/worktree.ts:685

    }).trim();
    return nonEmpty(value);
  } catch {
    return null;
  }
}

function validateGitBranchName(cwd: string, branchName: string): string {
  const value = nonEmpty(branchName);
  if (!value) {
    throw new Error("Branch name is required.");
  }
  try {
    execFileSync("git", ["check-ref-format", "--branch", value], {
      cwd,
      stdio: ["ignore", "pipe", "pipe"],
    });
  } catch (error) {
    throw new Error(`Invalid branch name "${branchName}": ${extractExecSyncErrorMessage(error) ?? String(error)}`);
  }
  return value;
}

function isPrimaryGitWorktree(cwd: string): boolean {
  const workspace = detectGitWorkspaceInfo(cwd);
  return Boolean(workspace && workspace.gitDir === workspace.commonDir);
}

function resolvePrimaryGitRepoRoot(cwd: string): string {
  const workspace = detectGitWorkspaceInfo(cwd);
  if (!workspace) {
    throw new Error("Current directory is not inside a git repository.");
  }
  if (workspace.gitDir === workspace.commonDir) {
    return workspace.root;
  }
  return path.resolve(workspace.commonDir, "..");

View on GitHub (pinned to 01ad858492)