{"record":{"id":"84e368e994842f84","repo":"nikivdev/code","slug":"git-fetch-prune-failed","errorCode":null,"errorMessage":"git fetch {} --prune failed: {}","messagePattern":"git fetch (.+?) --prune failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sync.rs","lineNumber":3965,"sourceCode":") -> Result<()> {\n    let before_tip = remote_branch_tip(repo_root, remote, remote_branch);\n\n    match fetch_mode {\n        SyncRemoteFetchMode::FullRemote => {\n            let fetch = Command::new(\"git\")\n                .current_dir(repo_root)\n                .args([\"fetch\", remote, \"--prune\"])\n                .output()\n                .with_context(|| format!(\"failed to run git fetch {}\", remote))?;\n            if !fetch.status.success() {\n                let stderr = String::from_utf8_lossy(&fetch.stderr);\n                if stderr.contains(\"case-insensitive filesystem\") {\n                    sync_stderrln!(\n                        \"  Warning: {} has refs that differ only in case; fetch continued anyway\",\n                        remote\n                    );\n                } else {\n                    bail!(\"git fetch {} --prune failed: {}\", remote, stderr.trim());\n                }\n            }\n            recorder.record(stage, format!(\"fetched {}\", remote));\n        }\n        SyncRemoteFetchMode::SingleBranch => {\n            let refspec = format!(\n                \"+refs/heads/{}:refs/remotes/{}/{}\",\n                remote_branch, remote, remote_branch\n            );\n            git_run_in(repo_root, &[\"fetch\", remote, \"--prune\", &refspec])?;\n            recorder.record(stage, format!(\"fetched {} {}\", remote, remote_branch));\n        }\n    }\n\n    if remote == \"upstream\" {\n        let local_upstream_exists =\n            git_capture_in(repo_root, &[\"rev-parse\", \"--verify\", \"refs/heads/upstream\"]).is_ok();\n        if local_upstream_exists {","sourceCodeStart":3947,"sourceCodeEnd":3983,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L3947-L3983","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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`."],"exampleFix":"// before\nf sync\n// error: git fetch origin --prune failed: fatal: Authentication failed\n\n// after (fix auth, then retry)\nssh-add ~/.ssh/id_ed25519\ngit fetch origin --prune   # verify succeeds\nf sync","handlingStrategy":"retry","validationCode":"git ls-remote \"$REMOTE\" HEAD >/dev/null 2>&1 || { echo \"git fetch $REMOTE will fail: unreachable/auth\"; exit 1; }","typeGuard":null,"tryCatchPattern":"match sync::run(&repo_root, &cmd) {\n    Err(e) if e.to_string().starts_with(\"git fetch \") && e.to_string().contains(\"--prune failed\") => {\n        eprintln!(\"Fetch failed: {} — check remote auth/connectivity, then retry\", e);\n    }\n    other => other,\n}","preventionTips":["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."],"tags":["git","network","fetch","prune"],"backgroundTag":"git-fetch-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}