gitbutlerapp/gitbutler · error
Commit ID ' ' is ambiguous. Found matches
Error message
Commit ID '{}' is ambiguous. Found {} matches What it means
In `but show`, a user-supplied ID string is resolved to `CliId`s; if the string matches more than one object, `show_commit` cannot pick one and reports the number of matches. This guards against showing the wrong commit when short IDs or names are ambiguous.
Solutions
- Use a longer (ideally full 40-char) commit hash: `but show 12ab34cd...`.
- List candidates first (e.g. `but log` / `but branches`) and pick the exact ID.
- If your tooling passes IDs programmatically, resolve via the ID map with full IDs from prior command output.
Example fix
// before but show 12ab // error: ambiguous, 3 matches // after but show 12ab34cd56ef78ab90cd12ef34ab56cd78ab90cd
Defensive patterns
Strategy: validation
Validate before calling
fn disambiguate(ids: &[CliId], raw: &str) -> Result<&CliId, String> {
match ids {
[one] => Ok(one),
[] => Err(format!("no object matches '{raw}'")),
many => Err(format!("'{raw}' is ambiguous ({} matches); use a longer hash", many.len())),
}
} Try / catch
match result {
Err(e) if e.to_string().contains("is ambiguous") => {
eprintln!("use the full 40-character commit hash");
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Use full commit hashes in scripts, not short prefixes
- Resolve IDs from prior command output's full-ID fields
- Keep prefix length >= 8-12 chars when typing by hand
When it happens
Trigger: Passing a short commit hash prefix that matches multiple commits (e.g. `but show 12ab` where several objects start with `12ab`), when `cli_ids.len() > 1` after resolution.
Common situations: Very short hash prefixes in large repositories; copy-pasting a truncated hash; branch/tag and commit sharing a prefix in the ID map.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Ambiguous branch ' ', matches multiple items
- Ambiguous branch identifier
- CLI id ' ' is ambiguous for in IdMap
- Commit ID ' ' is ambiguous. Please provide more characters…
- Identifier ' ' matches multiple non-branch items. Please…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/b57ec69c2a24c6c9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/show.rs:67
}
}
// 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);
}
_ => {
bail!(
"Target must be a commit ID or branch, not {}",
cli_ids[0].kind_for_humans()View on GitHub (pinned to 58e5313667)