gitbutlerapp/gitbutler · error
Commit ID ' ' is ambiguous. Please provide more characters…
Error message
Commit ID '{commit_id_str}' is ambiguous. Please provide more characters to uniquely identify the commit. What it means
Resolution failure in parse_commit_id: the provided identifier is a prefix matching more than one commit, so it cannot be resolved uniquely. Provide more characters of the SHA/ID until the match is unambiguous.
Solutions
- Provide more characters of the commit ID until unique
- Use the full 40-character OID copied from `but status` or `git log`
Example fix
// before but resolve ab // after but resolve ab3f9c2 # longer unambiguous prefix
Defensive patterns
Strategy: validation
Validate before calling
let n = id_map_matches(input); // number of matches
if n > 1 { eprintln!("{input} is ambiguous; lengthen the prefix"); } Try / catch
if let Err(e) = parse_commit_id(ctx, input) {
if e.to_string().contains("ambiguous") {
eprintln!("Provide more characters of the commit id");
}
} Prevention
- Use at least 7+ characters of the commit ID
- Prefer full OIDs in automation
- Check for prefix collisions when generating short IDs
When it happens
Trigger: `but resolve <partial-id>` where the short ID prefix matches multiple commits/objects in the current workspace.
Common situations: Providing very short IDs (1-3 chars) in workspaces with many commits; ID prefixes shared between a commit and another entity type.
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 ' ' not found. Try running 'but status' to see…
- Commit ID ' ' is ambiguous. Found matches
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/e2e05bfff2c8b4d4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/resolve.rs:170
}
/// Resolve a user-provided commit identifier (CLI ID or partial SHA) to an
/// object id, along with its display ref rendered from the same map.
fn parse_commit_id(ctx: &mut Context, commit_id_str: &str) -> Result<(gix::ObjectId, String)> {
// Create an IdMap to resolve commit IDs (supports both CLI IDs and partial SHAs)
let id_map = IdMap::legacy_new_from_context(ctx)?;
// Resolve the commit ID using the IdMap
let matches = id_map.parse_using_context(commit_id_str, ctx)?;
if matches.is_empty() {
bail!(
"Commit '{commit_id_str}' not found. Try running 'but status' to see available commits."
);
}
if matches.len() > 1 {
bail!(
"Commit ID '{commit_id_str}' is ambiguous. Please provide more characters to uniquely identify the commit."
);
}
// 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))View on GitHub (pinned to 58e5313667)