yamadashy/repomix · error · RepomixError

Failed to get remote refs: ${redactErrorMessage(error)}

Error message

Failed to get remote refs: ${redactErrorMessage(error)}

What it means

Repomix wraps any failure while listing a remote repository's refs (branches/tags) into this RepomixError, with the underlying git command error redacted so credentials are not leaked. It means the `git ls-remote`-style operation against `url` did not succeed.

Source

Thrown at src/core/git/gitRemoteHandle.ts:59

    // Format is: hash\tref_name
    const refs = stdout
      .split('\n')
      .filter(Boolean)
      .map((line) => {
        // Skip the hash part and extract only the ref name
        const parts = line.split('\t');
        if (parts.length < 2) return '';

        // Remove 'refs/heads/' or 'refs/tags/' prefix
        return parts[1].replace(/^refs\/(heads|tags)\//, '');
      })
      .filter(Boolean);

    logger.trace(`Found ${refs.length} refs in repository: ${redactUrl(url)}`);
    return refs;
  } catch (error) {
    logger.trace('Failed to get remote refs:', redactErrorMessage(error));
    throw new RepomixError(`Failed to get remote refs: ${redactErrorMessage(error)}`);
  }
};

View on GitHub (pinned to f465ad9093)

Solutions

  1. Read the redacted cause in the message to identify auth vs network failure.
  2. Run `git ls-remote <url>` manually to reproduce and see the full git error.
  3. Fix credentials: configure SSH keys or a token (git credential helper) for the host.
  4. Verify the URL and network (VPN/proxy/DNS) then retry.

Example fix

// before
await getRemoteRefs('git@github.com:org/private-repo.git'); // fails: no SSH key
// after: ensure key exists or use HTTPS with token
await getRemoteRefs('https://github.com/org/private-repo.git');
Defensive patterns

Strategy: retry

Validate before calling

import { execFileSync } from 'node:child_process';
const probe = (url: string) => execFileSync('git', ['ls-remote', url, 'HEAD'], { stdio: 'pipe' });
// call before repomix: probe(url) throws with the full git error if unreachable

Type guard

null

Try / catch

try {
  await repomixCli.run(['--remote', url]);
} catch (e) {
  if (String(e?.message).startsWith('Failed to get remote refs')) {
    // retry with backoff for transient network errors; surface cause for auth issues
  }
}

Prevention

When it happens

Trigger: getRemoteRefs(url) fails because the remote is unreachable, authentication failed, the repository does not exist or is private, the URL scheme is unsupported, or git is not installed/offline.

Common situations: Expired/missing credentials for a private repo; typo in remote URL; corporate proxy or firewall blocking git; cloning on a machine without git credentials configured (ssh keys, GCM token); network outage in CI.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/fe06178134715f3e. Report an issue: GitHub.