gitbutlerapp/gitbutler · error
Identifier ' ' matches multiple non-branch items. Please…
Error message
Identifier '{branch_id}' matches multiple non-branch items. Please use a branch name or branch CLI ID. What it means
The identifier matched multiple CliIds, but none of them are branch items (e.g. commits or other workspace entities). Since `but push` only accepts a branch, it asks for a branch name or a branch CLI ID.
Solutions
- Use a branch name instead of the matching identifier.
- Get the branch's CLI ID from `but branch list` and use that.
- If you meant to push a commit's changes, first assign/move it to a branch, then push that branch.
Example fix
// before but push c1 // after but push feature/login
Defensive patterns
Strategy: validation
Validate before calling
if (!isBranchCliId(id) && !listBranches().some(b => b.name === id)) {
throw new Error(`"${id}" is not a branch; pass a branch name or branch CLI ID`);
}
butPush(id); Try / catch
const out = await exec('but', ['push', id]);
if (out.code !== 0 && /matches multiple non-branch items/.test(out.stderr)) {
console.error(`"${id}" is not a branch. Use: but branch list`);
} Prevention
- Do not feed commit CLI IDs to but push
- Resolve branch identifiers from but branch list, not from log output of commits
- Validate the target is a branch before scripting the push
When it happens
Trigger: Passing an identifier to `but push` that matches several non-branch objects (e.g. multiple commits sharing a CliId prefix); cli_ids is non-empty but branch_names is empty in resolve_branch_name.
Common situations: Copy-pasting a commit CLI ID into `but push`, abbreviated IDs that resolve to commits in a stacked workspace, confusing commit IDs with branch IDs.
Related errors
- Ambiguous branch identifier
- Ambiguous branch ' ', matches multiple items
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch ' ' not found. Available branches
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/c6ee69404c147cdf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/push.rs:1127
}
if cli_ids.len() > 1 {
let branch_names: Vec<String> = cli_ids
.iter()
.filter_map(|id| match id {
CliId::Branch(branch) => Some(branch.name.clone()),
_ => None,
})
.collect();
if !branch_names.is_empty() {
return Err(anyhow::anyhow!(
"Ambiguous branch identifier '{}'. Did you mean one of:\n{}",
branch_id,
format_branch_suggestions(&branch_names)
));
} else {
return Err(anyhow::anyhow!(
"Identifier '{branch_id}' matches multiple non-branch items. Please use a branch name or branch CLI ID."
));
}
}
match &cli_ids[0] {
CliId::Branch(branch) => Ok(branch.name.clone()),
CliId::Worktree { name, .. } => {
let repo = ctx.repo.get()?;
let branch = crate::utils::worktrees::worktree_branch(&repo, name.as_ref())?;
Ok(branch.shorten().to_string())
}
_ => Err(anyhow::anyhow!(
"Expected branch identifier, got {}. Please use a branch name or branch CLI ID.",
cli_ids[0].kind_for_humans()
)),
}
}View on GitHub (pinned to 58e5313667)