nikivdev/code · error
git fetch {} --prune failed: {}
Error message
git fetch {} --prune failed: {} What it means
Thrown in src/sync.rs when a plain `git fetch <remote> --prune` fails during the sync remote-fetch stage. The stderr is checked first: a 'case-insensitive filesystem' warning is tolerated, but any other failure bails with the remote name and trimmed stderr. Fetches update remote-tracking refs and prune deleted ones.
Source
Thrown at src/sync.rs:3965
) -> Result<()> {
let before_tip = remote_branch_tip(repo_root, remote, remote_branch);
match fetch_mode {
SyncRemoteFetchMode::FullRemote => {
let fetch = Command::new("git")
.current_dir(repo_root)
.args(["fetch", remote, "--prune"])
.output()
.with_context(|| format!("failed to run git fetch {}", remote))?;
if !fetch.status.success() {
let stderr = String::from_utf8_lossy(&fetch.stderr);
if stderr.contains("case-insensitive filesystem") {
sync_stderrln!(
" Warning: {} has refs that differ only in case; fetch continued anyway",
remote
);
} else {
bail!("git fetch {} --prune failed: {}", remote, stderr.trim());
}
}
recorder.record(stage, format!("fetched {}", remote));
}
SyncRemoteFetchMode::SingleBranch => {
let refspec = format!(
"+refs/heads/{}:refs/remotes/{}/{}",
remote_branch, remote, remote_branch
);
git_run_in(repo_root, &["fetch", remote, "--prune", &refspec])?;
recorder.record(stage, format!("fetched {} {}", remote, remote_branch));
}
}
if remote == "upstream" {
let local_upstream_exists =
git_capture_in(repo_root, &["rev-parse", "--verify", "refs/heads/upstream"]).is_ok();
if local_upstream_exists {View on GitHub (pinned to a747e741ae)
Solutions
- Read the stderr embedded in the message for the concrete cause and address it (auth, network, or remote URL).
- Test connectivity/auth manually: `git fetch <remote> --prune` in the repo to reproduce outside the tool.
- Fix credentials: load the SSH key into the agent or refresh the HTTPS token in the credential helper.
- Verify the remote exists and the URL is current with `git remote -v`; update via `git remote set-url`.
Example fix
// before f sync // error: git fetch origin --prune failed: fatal: Authentication failed // after (fix auth, then retry) ssh-add ~/.ssh/id_ed25519 git fetch origin --prune # verify succeeds f sync
Defensive patterns
Strategy: retry
Validate before calling
git ls-remote "$REMOTE" HEAD >/dev/null 2>&1 || { echo "git fetch $REMOTE will fail: unreachable/auth"; exit 1; } Try / catch
match sync::run(&repo_root, &cmd) {
Err(e) if e.to_string().starts_with("git fetch ") && e.to_string().contains("--prune failed") => {
eprintln!("Fetch failed: {} — check remote auth/connectivity, then retry", e);
}
other => other,
} Prevention
- Pre-flight with a manual `git fetch <remote> --prune` in scripts/CI before invoking sync.
- Keep credentials fresh (ssh-agent, credential helper) and test with `git ls-remote`.
- Verify remote URLs after org/repo renames with `git remote -v`.
- Retry fetches with backoff on transient network failures.
When it happens
Trigger: The SyncRemoteFetchMode::All path runs `git fetch <remote> --prune` and it exits non-zero with stderr that does not mention 'case-insensitive filesystem' — e.g., auth failure, unknown remote, DNS failure, or refspec lock errors.
Common situations: Remote credentials expired or SSH agent lacks the key; remote URL points at a deleted/renamed repo; offline/VPN down; packed-refs permission issues in .git.
Related errors
- jj git fetch failed: {}
- git pull failed
- git push failed
- jj git export retry loop should always return
- Lin.app is not running
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/84e368e994842f84.
Report an issue: GitHub.