{"record":{"id":"f3fe818e87a214da","repo":"denoland/deno","slug":"git-failed","errorCode":null,"errorMessage":"`git {}` failed: {}","messagePattern":"`git (.+?)` failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/util/git.rs","lineNumber":26,"sourceCode":"use tokio::process::Command;\n\n/// Run `git` with `args` in `cwd`, returning stdout on success.\npub fn run_git(cwd: &Path, args: &[&str]) -> Result<String, AnyError> {\n  let output = match std::process::Command::new(\"git\")\n    .current_dir(cwd)\n    .args(args)\n    .output()\n  {\n    Ok(output) => output,\n    Err(err) => {\n      return Err(anyhow!(\n        \"Failed to run `git {}`: {err}. Is git installed and on PATH?\",\n        args.join(\" \")\n      ));\n    }\n  };\n  if !output.status.success() {\n    return Err(anyhow!(\n      \"`git {}` failed: {}\",\n      args.join(\" \"),\n      String::from_utf8_lossy(&output.stderr).trim()\n    ));\n  }\n  Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\npub async fn check_if_git_repo_dirty(cwd: &Path) -> Option<String> {\n  let bin_name = if cfg!(windows) { \"git.exe\" } else { \"git\" };\n\n  //  Check if git exists\n  let git_exists = Command::new(bin_name)\n    .arg(\"--version\")\n    .stderr(Stdio::null())\n    .stdout(Stdio::null())\n    .status()\n    .await","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/util/git.rs#L8-L44","documentation":"git was spawned successfully but exited non-zero. The failing arguments and git's trimmed stderr are embedded in the message, so the underlying git failure — not a deno bug — explains the problem.","triggerScenarios":"Running git in a directory that is not a repository, referencing missing refs, credential/permission failures for remote operations, or any arguments git itself rejects.","commonSituations":"Workflows that check repo cleanliness in a non-repo directory; shallow clones missing an expected ref; auth failures in CI for fetch/clone operations.","solutions":["Reproduce manually with the exact command shown in the message from the same directory — git's own stderr usually states the fix","For 'not a git repository' errors: run from a repo root or initialize one with `git init`","For network/auth failures: verify credentials and remote URLs, then retry once connectivity is restored"],"exampleFix":"# message: `git status --porcelain` failed: fatal: not a git repository\n# before: run deno outside any repo\ncd /tmp && deno release\n# after\ncd ~/myrepo && deno release","handlingStrategy":"try-catch","validationCode":"# bash: verify the directory is a repo before git-dependent commands\ngit -C \"$PWD\" rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo \"not a git repo\" >&2; exit 1; }\ndeno release","typeGuard":null,"tryCatchPattern":"# bash: surface git's stderr from deno's wrapper message\nif ! deno release 2>err.log; then\n  sed -n 's/^`git \\([^`]*\\)` failed: /git \\1 failed: /p' err.log\n  exit 1\nfi","preventionTips":["Reproduce the embedded git command manually to see git's own guidance","Ensure CI clones are complete enough (refs present) for the command deno runs","Check credentials and remote access before network git operations"],"tags":["git","process","repository","external-tool"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}