Hmbown/CodeWhale · error
git archive origin/main failed
Error message
git archive origin/main failed: {} What it means
materialize_ops_origin_main runs `git archive origin/main` into a buffer to materialize the ops (AUTO_MERGE / check script) tree from the remote-tracking main branch. This error wraps the git command's non-zero exit and surfaces git's own stderr.
Solutions
- Run `git fetch origin main` to create/update the origin/main ref
- Verify `git rev-parse origin/main` resolves in the repo
- Check remote configuration (`git remote -v`) and add/repair origin if missing
- Inspect the wrapped stderr in the message for the underlying git cause
Example fix
// before (shell) materialize_ops_origin_main(...) # assumes origin/main exists // after (shell) git fetch origin main && materialize_ops_origin_main(...)
Defensive patterns
Strategy: try-catch
Validate before calling
let has_ref = std::process::Command::new("git").args(["rev-parse","--verify","origin/main"]).output().map(|o| o.status.success()).unwrap_or(false); Try / catch
match materialize_ops_origin_main(dest) { Err(e) if e.to_string().contains("git archive origin/main failed") => { run_cmd("git fetch origin main")?; retry_once(materialize_ops_origin_main, dest)?; } other => other?, } Prevention
- Run `git fetch origin main` before operate discovery
- Verify `git rev-parse origin/main` in preflight
- Keep origin remote configured in CI and containers
When it happens
Trigger: `git archive origin/main` exits non-zero — origin/main ref missing or stale, repository without that remote branch, corrupt objects, or git not able to read the ref.
Common situations: Fresh clone where origin/main has not been fetched; repo checked out without the origin remote; shallow clone lacking the ref; network-fetch failures leaving origin/main absent.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- gh pr checkout # failed
- git apply failed
- git diff failed
- git worktree add failed for branch
- ops origin/main archive missing
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/c1a78316fa10341f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/operate.rs:893
fs::create_dir_all(&dest).with_context(|| format!("Failed to create {}", dest.display()))?;
let archive = Command::new("git")
.arg("-C")
.arg(&repo)
.args([
"archive",
"origin/main",
"--",
"DIRECTION.md",
CHECK_AUTO_MERGE_SCRIPT,
AUTO_MERGE_SCRIPT,
AUTO_MERGE_PR_SCRIPT,
"agent-workstreams/AUTO_MERGE.toml",
])
.stdin(Stdio::null())
.output()
.context("git archive origin/main")?;
if !archive.status.success() {
anyhow::bail!(
"git archive origin/main failed: {}",
String::from_utf8_lossy(&archive.stderr).trim()
);
}
let mut child = Command::new("tar")
.arg("-x")
.arg("-C")
.arg(&dest)
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::piped())
.spawn()
.context("tar extract ops origin/main")?;
if let Some(mut stdin) = child.stdin.take() {
use std::io::Write;
stdin.write_all(&archive.stdout)?;
}
let status = child.wait()?;View on GitHub (pinned to 73e0f67d83)