paperclipai/paperclip · error · Error

Failed to fetch from remote "${remote}": ${extractExecSyncEr

Error message

Failed to fetch from remote "${remote}": ${extractExecSyncErrorMessage(error) ?? String(error)}

What it means

Thrown when `git fetch <remote>` fails during worktreeMakeCommand. The startPoint string is split on '/' to derive the remote name (e.g. "origin/main" -> "origin"); if `git fetch` for that remote exits non-zero, the execFileSync error is surfaced via extractExecSyncErrorMessage. This fetch is only attempted when a startPoint (remote branch) is supplied so the worktree can be created from up-to-date remote refs.

Source

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

  const name = resolveWorktreeMakeName(nameArg);
  const startPoint = resolveWorktreeStartPoint(opts.startPoint);
  const sourceCwd = process.cwd();
  const sourceConfigPath = resolveSourceConfigPath(opts);
  const targetPath = resolveWorktreeMakeTargetPath(name);
  if (existsSync(targetPath)) {
    throw new Error(`Target path already exists: ${targetPath}`);
  }

  mkdirSync(path.dirname(targetPath), { recursive: true });
  if (startPoint) {
    const [remote] = startPoint.split("/", 1);
    try {
      execFileSync("git", ["fetch", remote], {
        cwd: sourceCwd,
        stdio: ["ignore", "pipe", "pipe"],
      });
    } catch (error) {
      throw new Error(
        `Failed to fetch from remote "${remote}": ${extractExecSyncErrorMessage(error) ?? String(error)}`,
      );
    }
  }

  const worktreeArgs = resolveGitWorktreeAddArgs({
    branchName: name,
    targetPath,
    branchExists: !startPoint && localBranchExists(sourceCwd, name),
    startPoint,
  });

  const spinner = p.spinner();
  spinner.start(`Creating git worktree at ${targetPath}...`);
  try {
    execFileSync("git", worktreeArgs, {
      cwd: sourceCwd,
      stdio: ["ignore", "pipe", "pipe"],

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Confirm the remote exists and is reachable: `git remote -v` then `git fetch <remote>` manually to see the real git error.
  2. Fix auth (SSH key, credential helper, PAT) for the remote.
  3. If you don't need the latest remote ref, omit --start-point to branch from the current HEAD instead.
  4. Retry once transient network issues are resolved.

Example fix

// before
paperclipai worktree:make feat-x --start-point origin/feat-x   # fetch fails
// after (branch from local HEAD, no fetch needed)
paperclipai worktree:make feat-x
Defensive patterns

Strategy: try-catch

Validate before calling

import { execFileSync } from "node:child_process";
function remoteFetchable(remote: string, cwd: string): boolean {
  try {
    execFileSync("git", ["fetch", remote, "--dry-run"], { cwd, stdio: "ignore" });
    return true;
  } catch { return false; }
}

Type guard

function startPointHasRemote(sp: string): boolean {
  return /^[A-Za-z0-9._-]+\//.test(sp) && sp.split("/")[0].length > 0;
}

Try / catch

try { /* fetch */ }
catch (err) {
  if (/Failed to fetch from remote/.test(String((err as Error).message))) {
    // fall back: create worktree from local HEAD by dropping --start-point
  } else throw err;
}

Prevention

When it happens

Trigger: Passing `--start-point origin/feat-x` when offline or when the remote is unreachable; the remote name in the start point does not exist (`git remote -v`); network/firewall blocks the fetch; auth failure for a private remote; malformed start point with no valid remote segment.

Common situations: No network / VPN down; remote URL changed but git config still points at old URL; SSH key or token not configured for the remote; typo in the start-point remote prefix.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/0ea86d16414def36. Report an issue: GitHub.