gitbutlerapp/gitbutler · error
Could not create repository bundle
Error message
Could not create repository bundle: {} What it means
create_bundle shells out to `git bundle create --quiet <path> --all HEAD --not --remotes` to build a repository bundle. If git exits non-zero, the function bails including git's trimmed stderr, so the underlying git error is surfaced verbatim.
Solutions
- Read the stderr in the message for the underlying git failure and fix that cause (e.g. bad ref, permission)
- Verify the repository has at least one commit reachable from HEAD before bundling
- Check that bundle_path's parent directory exists and is writable
- Run `git bundle create <path> --all HEAD --not --remotes` manually in the repo to reproduce and diagnose
- Run `git fsck` if object corruption is reported
Example fix
// before
// failing: empty repo, no HEAD
create_bundle(repo_path, bundle_path)?;
// after
if repo.head_id().is_err() {
anyhow::bail!("repository has no commits; nothing to bundle");
}
create_bundle(repo_path, bundle_path)?; Defensive patterns
Strategy: try-catch
Validate before calling
let has_head = Command::new("git").arg("rev-parse").arg("HEAD")
.current_dir(&repo_path).output()?.status.success();
if !has_head { anyhow::bail!("repo has no HEAD; nothing to bundle"); } Try / catch
match installer.create_bundle(&repo_path, &bundle_path) {
Err(e) if e.to_string().contains("Could not create repository bundle") => {
eprintln!("git bundle failed: {e}; check refs/permissions and run git fsck");
}
other => other?,
} Prevention
- Verify HEAD resolves and the object store is healthy (git fsck) before bundling
- Ensure the bundle output directory exists and is writable
- Keep git installed and on PATH at a supported version
When it happens
Trigger: Calling create_bundle (from run) where the spawned `git bundle create` process returns a non-zero exit status — e.g. a repository with no HEAD/commits, a corrupt object database, or an unwritable bundle_path.
Common situations: Bare/empty repository with no HEAD commit to bundle, read-only or missing target directory for the bundle file, broken refs (`--all` failing on a malformed ref), or git not able to read the object store (corruption, wrong workdir).
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
- {}
- Aborting due to empty branch name
- Bare repositories are not supported.
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/2e9509591c6ad17a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-debug/src/command/dump/repo_installer.rs:189
.map(|name| {
name.as_bstr()
.to_str()
.context("HEAD reference name is not UTF-8")
.map(ToOwned::to_owned)
})
.transpose()?;
Ok((oid, reference))
}
fn create_bundle(workdir: &Path, bundle_path: &Path) -> Result<()> {
let output = git_command(workdir)?
.args(["bundle", "create", "--quiet"])
.arg(bundle_path)
.args(["--all", "HEAD", "--not", "--remotes"])
.output()
.context("Could not start git bundle creation")?;
if !output.status.success() {
bail!(
"Could not create repository bundle: {}",
String::from_utf8_lossy(&output.stderr).trim()
);
}
Ok(())
}
fn selected_local_config(workdir: &Path) -> Result<Vec<u8>> {
let output = git_command(workdir)?
.args([
"config",
"--local",
"--includes",
"--null",
"--get-regexp",
r"^(gitbutler\.|remote\.|log\.excludedecoration$)",
])
.output()View on GitHub (pinned to 58e5313667)