gitbutlerapp/gitbutler · error
snapshot checkout commit
Error message
snapshot checkout commit {} is unavailable What it means
Thrown by `restore_snapshot` after the snapshot's checkout identity has been reconstructed: the `SnapshotCheckout.commit_id` is not present in the repository. Unlike the workspace commits, the checkout commit has no serialized-parts fallback, so if the object is missing (e.g. pruned by gc or absent in a copied repo) the restore cannot proceed.
Solutions
- Fetch the missing commit from the remote (`git fetch origin` or `git fetch --unshallow`)
- Restore an earlier snapshot entry whose checkout commit still exists
- Avoid `git gc --prune=now`/aggressive pruning in GitButler-managed repos; loosen `gc.pruneExpire`
- If the commit is unrecoverable, recreate the branch at the closest surviving commit and take a fresh snapshot
Example fix
// checkout commit abc123 was pruned // before: restore fails with 'snapshot checkout commit abc123 is unavailable' // after: git fetch --unshallow origin # object restored, retry restore
Defensive patterns
Strategy: retry
Validate before calling
let checkout = gix::ObjectId::from_hex(hex_str)?;
if !repo.has_object(checkout) {
run("git fetch --unshallow origin")?; // pull missing objects before restore
} Try / catch
// catch and attempt to recover the object, then retry once
if let Err(e) = restore_snapshot(entry) {
if e.to_string().contains("is unavailable") {
run("git fetch origin")?;
restore_snapshot(entry)?;
} else { return Err(e); }
} Prevention
- Never unshallow a GitButler-managed repo without a full fetch afterwards
- Loosen `gc.pruneExpire` so snapshot-referenced commits survive pruning
- Fetch from remotes before restoring old snapshots
- Verify `repo.has_object` on snapshot heads in pre-restore checks
When it happens
Trigger: `restore_snapshot` finds `restored_checkout` and `!repo.has_object(checkout.commit_id)` — the commit referenced by the snapshot's checkout ref blob does not exist locally.
Common situations: Running `git gc`/`git prune` with aggressive expiration while snapshots still referenced old commits; restoring snapshots in a fresh clone that lacks historical objects; shallow clones missing the commit.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Base commit must exist if provided
- cannot restore a snapshot without checkout identity outside…
- Cannot restore branch
- cannot snapshot a null target commit id
- commit id mismatch: failed to recreate a commit from its…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/cbd70a1f38ac7716.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-oplog/src/oplog.rs:1135
// check for the oid in the repo
let commit_oid = gix::ObjectId::from_hex(commit_id)?;
if !repo.has_object(commit_oid) {
// commit is not in the repo, let's build it from our data
let new_commit_oid = deserialize_commit(commit_entry.id())?;
if new_commit_oid != commit_oid {
bail!("commit id mismatch: failed to recreate a commit from its parts");
}
}
// TODO: in the next iteration, this of course can't be hardcoded.
if branch_name == "workspace" {
restored_workspace_commit = Some(commit_oid);
}
}
}
if let Some(checkout) = restored_checkout.as_ref() {
if !repo.has_object(checkout.commit_id) {
bail!(
"snapshot checkout commit {} is unavailable",
checkout.commit_id
);
}
if checkout.ref_name == workspace_ref
&& restored_workspace_commit != Some(checkout.commit_id)
{
bail!("snapshot checkout and workspace commits disagree");
}
}
// Managed snapshots already identify their checkout through the workspace commit entry.
let restored_checkout = restored_checkout.or_else(|| {
restored_workspace_commit.map(|commit_id| SnapshotCheckout {
ref_name: workspace_ref.to_owned(),
commit_id,
})
});
View on GitHub (pinned to 58e5313667)