gitbutlerapp/gitbutler · error
snapshot checkout and workspace commits disagree
Error message
snapshot checkout and workspace commits disagree
What it means
Thrown by `restore_snapshot` when the snapshot's checkout entry points at the workspace ref but the commit recorded there disagrees with the workspace commit reconstructed from the snapshot's commit entries. The two redundant encodings of the workspace head must agree; disagreement means the snapshot data is internally inconsistent (corrupt or produced by incompatible code paths).
Solutions
- Restore a different snapshot entry with consistent internal data
- Inspect the snapshot tree (`git ls-tree`) and align the checkout-commit blob with the workspace commit entry if you know the intended head
- Upgrade/downgrade GitButler so the snapshot format version matches the one that wrote the snapshot
- Clear the oplog and re-snapshot current state if the snapshot set is inconsistent
Example fix
// checkout blob says abc123, workspace commit entry says def456 // before: bail 'snapshot checkout and workspace commits disagree' // after: fix checkout blob to def456 (or restore consistent snapshot)
Defensive patterns
Strategy: validation
Validate before calling
// assert the two encodings agree before calling restore
if checkout.ref_name == workspace_ref
&& restored_workspace_commit != Some(checkout.commit_id) {
return Err("snapshot data inconsistent; pick another snapshot entry");
} Prevention
- Never mix snapshot blobs from different oplog entries or versions
- Restore whole snapshot entries, not hand-assembled subsets
- Keep GitButler updated so snapshot write paths stay consistent
- Compare the checkout blob and workspace commit entry with `git ls-tree` when in doubt
When it happens
Trigger: `restore_snapshot` sees `checkout.ref_name == workspace_ref` while `restored_workspace_commit != Some(checkout.commit_id)` — e.g. the checkout blob was edited, or commit entries and the checkout blob were written by different snapshot versions.
Common situations: Manually editing snapshot blobs; mixing snapshot data across GitButler versions; partially copied/restored oplog trees where some blobs came from a different snapshot.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- 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…
- Commit is not a snapshot
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/4e839eec6edfe47b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-oplog/src/oplog.rs:1143
}
// 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,
})
});
let head = repo.head()?;
let head_ref = head
.referent_name()
.context("We will not change a worktree in detached HEAD state")?;
// Snapshots with neither checkout identity nor a workspace commit retain the old guard.
if restored_checkout.is_none() && head_ref != workspace_ref {
bail!("cannot restore a snapshot without checkout identity outside the workspace branch");
}View on GitHub (pinned to 58e5313667)