nikivdev/code · error
git clone failed
Error message
git clone failed
What it means
clone_git_like runs `git clone` with inherited stdio and bails if the process exits non-zero. The generic message means git itself reported the failure; the actual cause (auth, network, bad URL) was already printed to the terminal via inherited stderr.
Source
Thrown at src/repos.rs:93
}
}
let clone_url = resolve_git_like_clone_url(&opts.url)?;
let mut cmd = Command::new("git");
cmd.arg("clone").arg(&clone_url);
if let Some(dir) = opts.directory {
cmd.arg(dir);
}
let status = cmd
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.context("failed to run git clone")?;
if !status.success() {
bail!("git clone failed");
}
Ok(())
}
fn open_in_zed(path: &std::path::Path) -> Result<()> {
let try_open = |app: &str| -> Result<()> {
let status = std::process::Command::new("open")
.args(["-a", app])
.arg(path)
.status()
.with_context(|| format!("failed to open {app}"))?;
if !status.success() {
bail!("{app} exited with status {status}");
}
Ok(())
};
View on GitHub (pinned to a747e741ae)
Solutions
- Read the git output above the error for the exact cause
- Verify the clone URL (try cloning with plain `git clone <url>` to reproduce)
- For SSH: confirm access with `ssh -T git@host`; for HTTPS: refresh credentials/token
- Ensure the destination directory doesn't already exist or is empty
Example fix
// before (typo) f clone git@github.com:org/repo.git // repo doesn't exist // after f clone git@github.com:org/repo.git // correct, existing repo
Defensive patterns
Strategy: retry
Validate before calling
const { execSync } = require("child_process");
function canReachRemote(url) {
try { execSync(`git ls-remote ${url} HEAD`, { stdio: "ignore" }); return true; }
catch { return false; }
}
if (!canReachRemote(url)) throw new Error(`cannot access ${url}; fix URL/auth before cloning`); Try / catch
async function cloneWithRetry(url, dest, attempts = 2) {
for (let i = 0; i < attempts; i++) {
try { return run(["f", "clone", url, dest]); }
catch (e) {
if (i === attempts - 1) throw e;
await sleep(1000 * (i + 1)); // transient network failures only
}
}
} Prevention
- Verify the repo URL and access with `git ls-remote <url>` before cloning
- Keep SSH keys/HTTPS tokens authorized and unexpired for the remote host
- Ensure the destination path is new or empty; check network/DNS before batch clones
When it happens
Trigger: `git clone` exits non-zero during a `f` clone (any git-level failure).
Common situations: Repository URL wrong or repo doesn't exist; SSH key not authorized for the remote; HTTPS token expired; network/DNS failure; target directory already exists and is non-empty; insufficient permissions on a private repo.
Related errors
- git {} failed
- {} failed with status {}
- git {} failed: {}
- SSH mode is forced but no key is available. Run `f ssh setup
- git {} failed
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/46376d512b5729f1.
Report an issue: GitHub.