gitbutlerapp/gitbutler · error
' ' does not refer to a commit
Error message
'{commit_id_str}' does not refer to a commit What it means
Type guard in parse_commit_id: the identifier resolved to a CliId that is not a Commit variant (e.g. a branch, hunk, or worktree ID). Only commit identifiers can be used for conflict resolution, so a different ID must be supplied.
Solutions
- Pass a commit ID from `but status` rather than a file path or branch name
- To resolve uncommitted file conflicts, pass conflicted file paths only (with no commit-like target)
- Check the entity type with `but status` before invoking
Example fix
// before but resolve main # branch name, not a commit id // after but resolve 9f2c1ab # actual commit id
Defensive patterns
Strategy: type-guard
Validate before calling
if let Some(kind) = id_kind(input) { // 'commit' | 'file' | 'branch'
if kind != "commit" { eprintln!("{input} is not a commit id"); }
} Type guard
fn is_commit_id(id: &str, ctx: &Context) -> bool {
matches!(id_kind(id, ctx), Some(Kind::Commit))
} Try / catch
if let Err(e) = parse_commit_id(ctx, input) {
if e.to_string().contains("does not refer to a commit") {
eprintln!("{input} resolves to a non-commit; pass a commit id from 'but status'");
}
} Prevention
- Distinguish file paths, branch names, and commit IDs before calling
- Use unambiguous commit IDs from `but status`
- Do not pass branch names to commit-targeted commands
When it happens
Trigger: `but resolve <id>` where the ID maps to a non-commit entity — e.g. passing a file path or branch name where the match falls into the non-commit arm of the match on matches[0].
Common situations: Passing a file path when a commit is expected; using a branch name instead of a commit ID; confusing `but resolve <path>` (worktree conflicts) with `but resolve <commit>` (commit resolution).
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
- Commit ' ' not found. Try running 'but status' to see…
- Commit ID ' ' is ambiguous. Please provide more characters…
- ' ' is not a commit
- Expected a branch ID, got
- Expected branch identifier, got
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/174b40dddf2159d0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/resolve.rs:190
);
}
// Extract the commit OID from the matched CliId
match &matches[0] {
CliId::Commit {
commit: CommitId { commit_id, .. },
id: _,
} => {
let commit_ref = theme::Commit(CommitIdRef {
commit_id: *commit_id,
change_id: id_map
.change_id_ref(*commit_id)
.map(|change_id| &change_id.change_id),
})
.to_string();
Ok((*commit_id, commit_ref))
}
_ => bail!("'{commit_id_str}' does not refer to a commit"),
}
}
fn enter_resolution(ctx: &mut Context, out: &mut OutputChannel, commit_id_str: &str) -> Result<()> {
let t = theme::get();
use gix::{prelude::ObjectIdExt as _, revision::walk::Sorting};
let (commit_gix_oid, commit_ref) = parse_commit_id(ctx, commit_id_str)?;
// Get the commit and check if it's conflicted
let repo = ctx.repo.get()?;
let commit = repo
.find_commit(commit_gix_oid)
.context("Failed to find commit")?;
if !commit.is_conflicted() {
bail!(
"Commit {commit_ref} is not in a conflicted state. Only conflicted commits can be resolved."View on GitHub (pinned to 58e5313667)