gitbutlerapp/gitbutler · error
' ' is not a commit
Error message
'{commit_id_str}' is not a commit What it means
After `rev_parse_single` successfully resolves the string, `show_commit` tries `try_into_commit()`. This error is returned when the resolved git object exists but is not a commit — e.g. it is a blob, tree, or tag object.
Solutions
- pass a commit id (from `but status` or `git log`) instead of a tree/blob/path id
- if showing a file is intended, use `but diff` / `git show <path>` instead
- deref the tag first, e.g. use the peeled commit id `git rev-parse <tag>^{commit}`
Example fix
// before but show HEAD:src/main.rs # resolves to a blob // after but show $(git rev-parse HEAD) # or a CLI id from `but status`
Defensive patterns
Strategy: validation
Validate before calling
let kind = String::from_utf8_lossy(&Command::new("git").args(["cat-file","-t",id]).output().unwrap().stdout).trim().to_string();
if kind != "commit" { eprintln!("{id} is a {kind}, not a commit"); } Try / catch
match show_commit(ctx, id) {
Err(e) if e.to_string().contains("is not a commit") => {
eprintln!("Pass a commit id (git rev-parse <ref>^{{commit}}) instead.");
}
other => other?,
} Prevention
- only pass commit ids to `but show`; use `but diff`/git for trees and blobs
- peel tags with `<tag>^{commit}`
- do not pass `rev:path` file expressions to commit-showing commands
When it happens
Trigger: Calling `but show <id>` where `<id>` resolves to a non-commit object: a tree hash, blob hash, a file path (rev-parse of `HEAD:path`), or an annotated tag when the caller expects a commit id.
Common situations: Passing a file path to `but show`, copying a tree/blob hash from `git cat-file` output, or passing a tag ref string that resolves to the tag object.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- " " does not refer to a commit or a branch
- 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/d2d64eb3aeacb969.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/show.rs:64
// Found the branch in a stack
return show_branch(ctx, out, &head_name, verbose, &id_map);
}
}
}
// Not a branch, resolve the commit ID through the IdMap
let cli_ids = id_map.parse_using_context(commit_id_str, ctx)?;
let commit_id = if cli_ids.is_empty() {
// If not found in IdMap, try to parse as a git commit ID directly
let repo = ctx.repo.get()?;
let obj = repo
.rev_parse_single(commit_id_str)
.map_err(|_| anyhow::anyhow!("Commit '{commit_id_str}' not found"))?;
let commit = obj
.object()?
.try_into_commit()
.map_err(|_| anyhow::anyhow!("'{commit_id_str}' is not a commit"))?;
commit.id
} else if cli_ids.len() > 1 {
bail!(
"Commit ID '{}' is ambiguous. Found {} matches",
commit_id_str,
cli_ids.len()
);
} else {
match &cli_ids[0] {
CliId::Commit {
commit: CommitId { commit_id, .. },
id: _,
} => *commit_id,
CliId::Branch(branch) => {
// This is a branch identified by CLI ID, show the branch
return show_branch(ctx, out, &branch.name, verbose, &id_map);
}
_ => {View on GitHub (pinned to 58e5313667)