gitbutlerapp/gitbutler · error
commit id mismatch: failed to recreate a commit from its…
Error message
commit id mismatch: failed to recreate a commit from its parts
What it means
Thrown by `restore_snapshot` when a snapshot commit is absent from the repository, so GitButler tries to rebuild it from the serialized commit parts stored in the snapshot, but the rebuilt commit's id differs from the id the snapshot claims. This is an internal consistency failure: the snapshot's data does not reproduce the commit it references, meaning the snapshot payload is corrupt or written by an incompatible version.
Solutions
- Restore a different snapshot entry from the oplog whose commits still exist in the repo
- Fetch/unshallow or undo a `git gc`/prune so missing objects return (`git fetch --unshallow`, restore from remote)
- Verify snapshot blob contents with `git ls-tree`/`git cat-file` and fix corrupted commit metadata if you know the intended values
- Reset the oplog and re-snapshot current state rather than restoring unreproducible commits
Example fix
// commit abc123 missing and rebuild yields def456 -> mismatch // fix: restore the missing object instead of relying on rebuild // git fetch origin 'refs/heads/*:refs/heads/*' # brings back abc123
Defensive patterns
Strategy: retry
Validate before calling
// pre-check that snapshot commits exist, else fetch before restoring
let oid = gix::ObjectId::from_hex(commit_id)?;
if !repo.has_object(oid) {
run("git fetch --all --tags")?;
} Try / catch
// on mismatch, fall back to another snapshot entry
match restore_snapshot(entry) {
Err(e) if e.to_string().contains("commit id mismatch") => {
restore_snapshot(earlier_entry)?
}
other => other?,
} Prevention
- Avoid `git gc --prune=now`/aggressive pruning in GitButler-managed repos
- Keep the repo fully fetched so referenced commits remain available
- Do not hand-edit or partially copy oplog snapshot trees
- Use matching GitButler versions when moving snapshots between machines
When it happens
Trigger: `restore_snapshot` encounters a commit entry whose oid (`from_hex(commit_id)`) is not in the repo (`!repo.has_object`), calls `deserialize_commit`, and `new_commit_oid != commit_oid`.
Common situations: Hand-edited or truncated snapshot trees; restoring snapshots across repos after garbage collection (`git gc`) removed the commit; snapshot format changes between GitButler versions; partial repository copies.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- cannot restore a snapshot without checkout identity outside…
- Cannot restore branch
- cannot snapshot a null target commit id
- Commit is not a snapshot
- snapshot additional ref target is null
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/5f974602c9b99573.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-oplog/src/oplog.rs:1123
let Some(commits_tree_entry) = commits_tree_entry else {
continue;
};
let commits_tree = repo
.find_tree(commits_tree_entry.id())
.context("failed to convert commits tree entry to tree")?;
// walk through all the commits in the branch
for commit_entry in commits_tree.iter() {
let commit_entry = commit_entry?;
// for each commit, recreate the commit from the commit data if it doesn't exist
let commit_id = commit_entry.filename();
// 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)View on GitHub (pinned to 58e5313667)