{"record":{"id":"6f1acf2bc431e4c8","repo":"yamadashy/repomix","slug":"failed-to-clone-repository-redacterrormessage-e","errorCode":null,"errorMessage":"Failed to clone repository: ${redactErrorMessage(error)}","messagePattern":"Failed to clone repository: (.+?)","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/cli/actions/remoteAction.ts","lineNumber":275,"sourceCode":"  logger.trace(`Created temporary directory. (path: ${pc.dim(tempDir)})`);\n  return tempDir;\n};\n\nexport const cloneRepository = async (\n  url: string,\n  directory: string,\n  remoteBranch?: string,\n  deps = {\n    execGitShallowClone,\n  },\n): Promise<void> => {\n  logger.log(`Clone repository: ${redactUrl(url)} to temporary directory. ${pc.dim(`path: ${directory}`)}`);\n  logger.log('');\n\n  try {\n    await deps.execGitShallowClone(url, directory, remoteBranch);\n  } catch (error) {\n    throw new RepomixError(`Failed to clone repository: ${redactErrorMessage(error)}`);\n  }\n};\n\nexport const cleanupTempDirectory = async (directory: string): Promise<void> => {\n  logger.trace(`Cleaning up temporary directory: ${directory}`);\n  await fs.rm(directory, { recursive: true, force: true });\n};\n\nexport const copyOutputToCurrentDirectory = async (\n  sourceDir: string,\n  targetDir: string,\n  outputFileName: string,\n): Promise<void> => {\n  const sourcePath = path.resolve(sourceDir, outputFileName);\n  const targetPath = path.resolve(targetDir, outputFileName);\n\n  // Skip copy if source and target are the same\n  // This can happen when an absolute path is specified for the output file","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/cli/actions/remoteAction.ts#L257-L293","documentation":"Repomix wraps any failure from the shallow git clone of a remote repository (used by `repomix --remote`) into a single RepomixError with a redacted error message. The thrown error could be an invalid URL, network failure, nonexistent repository/branch, or missing git binary; the library hides the raw stderr behind `redactErrorMessage` to avoid leaking credentials embedded in URLs.","triggerScenarios":"Calling `runRemoteAction`/`cloneRepository` (or `repomix --remote <url>`) where `deps.execGitShallowClone(url, directory, remoteBranch)` rejects: unreachable host, bad URL, auth required on a private repo, nonexistent branch passed via `--remote-branch`, or git not installed.","commonSituations":"Typing a wrong repo URL (typo in owner/name), cloning a private repo without SSH keys/credentials configured, offline or proxied networks blocking github.com, specifying a branch that doesn't exist, or corporate environments without git on PATH.","solutions":["Verify the repository URL is correct and reachable: `git ls-remote <url>`","If the repo is private, ensure credentials work (SSH keys or HTTPS token) for the user running repomix","Confirm git is installed and on PATH (`git --version`)","If using `--remote-branch`, check the branch exists in the remote","Check network/proxy connectivity to the git host"],"exampleFix":"// before\nawait repomixRemote('https://github.com/owner/no-such-repo');\n// after\nconst url = 'https://github.com/owner/real-repo';\nawait exec(`git ls-remote ${url}`); // validate first\nawait repomixRemote(url);","handlingStrategy":"try-catch","validationCode":"const { code } = spawnSync('git', ['ls-remote', url], { encoding: 'utf8' });\nif (code !== 0) throw new Error(`Repository unreachable: ${url}`);","typeGuard":"const isErrnoException = (e: unknown): e is NodeJS.ErrnoException =>\n  e instanceof Error && ('code' in e);","tryCatchPattern":"try {\n  await runRepomix({ remote: url });\n} catch (e) {\n  if (e instanceof RepomixError && e.message.startsWith('Failed to clone repository')) {\n    console.error('Check URL, credentials, network, and that git is installed.');\n  }\n  throw e;\n}","preventionTips":["Validate the repo URL with `git ls-remote` before invoking repomix","Keep git installed and credentials (SSH keys/tokens) configured","Test branch names with `git ls-remote --heads` before `--remote-branch`"],"tags":["git","network","remote-repository"],"backgroundTag":"git-clone-failed","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}