{"record":{"id":"805de16e2df89517","repo":"GoogleContainerTools/skaffold","slug":"failed-to-clone-repo-s-unable-to-find-any-matchi","errorCode":null,"errorMessage":"failed to clone repo %s: unable to find any matching refs %s; run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w","messagePattern":"failed to clone repo (.+?): unable to find any matching refs (.+?); run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/git/gitutil.go","lineNumber":167,"sourceCode":"\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: trouble checking repository remote; run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w\", g.Repo, err)\n\t\t} else if len(remotes) == 0 {\n\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: remote not set for existing clone\", g.Repo)\n\t\t}\n\n\t\t// if sync property is false, then skip fetching latest from remote and resetting the branch.\n\t\tif g.Sync != nil && !*g.Sync {\n\t\t\treturn repoCacheDir, nil\n\t\t}\n\n\t\t// if sync is turned off via flag `--sync-remote-cache`, then skip fetching latest from remote and resetting the branch.\n\t\tif opts.SyncRemoteCache.FetchDisabled() {\n\t\t\treturn repoCacheDir, nil\n\t\t}\n\n\t\ttryUpdateRemoteOriginFetchURL(ctx, r, g.RepoCloneURI)\n\n\t\tif _, err = r.Run(ctx, \"fetch\", \"origin\", ref); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: unable to find any matching refs %s; run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w\", g.Repo, ref, err)\n\t\t}\n\n\t\t// Sync option is either nil or true, so we are resetting the repo\n\t\tif _, err := r.Run(ctx, \"reset\", \"--hard\", fmt.Sprintf(\"origin/%s\", ref)); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to clone repo %s: trouble resetting branch to origin/%s; run 'git clone <REPO>; stat <DIR/SUBDIR>' to verify credentials: %w\", g.Repo, ref, err)\n\t\t}\n\t}\n\treturn repoCacheDir, nil\n}\n\n// gitCmd runs git commands in a git repo.\ntype gitCmd struct {\n\t// Dir is the directory the commands are run in.\n\tDir string\n}\n\n// Run runs a git command.\n// Omit the 'git' part of the command.","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/git/gitutil.go#L149-L185","documentation":"Thrown by syncRepo when updating an existing cached clone: `git fetch origin <ref>` fails, meaning the requested ref could not be fetched from origin. The message 'unable to find any matching refs' plus the credentials hint reflect the most common cause — the ref doesn't exist on the remote or access is denied. The raw git error is wrapped via %w.","triggerScenarios":"Cached clone exists, sync is enabled, and `git fetch origin <ref>` returns non-zero: unknown ref name, fetch URL pointing to a repo the user can't access, or network failure.","commonSituations":"Config ref renamed/deleted upstream (branch protection deleted branch); credentials expired for a private repo; offline or proxied environment; tryUpdateRemoteOriginFetchURL set origin to a URI the current environment can't authenticate against.","solutions":["Verify the ref exists and is reachable: git ls-remote <RepoCloneURI> <ref>; correct the ref in config if renamed.","Refresh credentials (ssh key, PAT/expired token) so fetch origin can authenticate.","Delete the cached clone and let skaffold re-clone: rm -rf <remote-cache-dir>/<hash>.","Check network/proxy settings; run git fetch origin <ref> inside the cached dir manually to see the raw error."],"exampleFix":"// before\nrepo: https://github.com/org/repo#release-1.0   # branch deleted upstream\n// after\nrepo: https://github.com/org/repo#release-1.1","handlingStrategy":"retry","validationCode":"const { execSync } = require('child_process');\nfunction refFetchable(uri, ref) {\n  try {\n    execSync(`git ls-remote --exit-code ${uri} ${ref}`, { stdio: 'pipe' });\n    return true;\n  } catch (e) {\n    console.error('ref not fetchable:', e.stderr?.toString() ?? e.message);\n    return false;\n  }\n}","typeGuard":"null","tryCatchPattern":"try {\n  await syncRepo(g, ctx, opts);\n} catch (err) {\n  if (/unable to find any matching refs/.test(err.message)) {\n    // transient network or expired creds: refresh creds and retry with backoff\n    await sleep(3000);\n    return syncRepo(g, ctx, opts);\n  }\n  throw err;\n}","preventionTips":["git ls-remote --exit-code <uri> <ref> in preflight to confirm the ref exists and is accessible.","Rotate tokens/keys before expiry in long-lived CI runners.","Delete the cached clone after any fetch failure so the next run starts clean.","Watch for upstream branch deletions/renames and update sync configs accordingly."],"tags":["git","fetch","ref-not-found","authentication"],"backgroundTag":"git-ref-fetch-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}