gitbutlerapp/gitbutler · error

Identifier '{branch_id}' matches multiple non-branch items.

Error message

Identifier '{branch_id}' matches multiple non-branch items. Please use a branch name or branch CLI ID.

What it means

The argument matched multiple entries in the IdMap but none of them are branches (commits, reviews, other id kinds), so the branch suggestion list cannot even be built. The generic message asks for a branch name or a branch CLI id instead.

Source

Thrown at crates/but/src/command/legacy/push.rs:1135

    }

    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()),
        _ => Err(anyhow::anyhow!(
            "Expected branch identifier, got {}. Please use a branch name or branch CLI ID.",
            cli_ids[0].kind_for_humans()
        )),
    }
}

fn get_available_branch_names(ctx: &Context) -> anyhow::Result<Vec<String>> {
    let stacks = crate::legacy::workspace::applied_stacks(ctx)?;
    let mut branch_names = Vec::new();

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Pass a branch name or a branch CLI id instead of a commit/review prefix
  2. Use a longer prefix or the exact id of the intended item
  3. List current branch names and ids with `but status`

Example fix

# before
but push 4a2f
# error: Identifier '4a2f' matches multiple non-branch items...

# after
but push feature-x   # a branch name or branch CLI id
Defensive patterns

Strategy: validation

Validate before calling

# Use branch names (or branch CLI ids) rather than commit/review prefixes
# verify the kind before scripting: ids shown by `but status` for branches
but status

Try / catch

let err = String::from_utf8_lossy(&out.stderr).to_string();
if err.contains("matches multiple non-branch items") {
    // ask for a branch name or branch CLI id and retry
}

Prevention

When it happens

Trigger: Passing a short prefix that matches several non-branch items, e.g. `but push 4a2f` where multiple commits or reviews share the prefix.

Common situations: Short SHA prefixes colliding in busy workspaces; ids copied from `but oplog` or review output mistaken for branch ids.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/c6ee69404c147cdf. Report an issue: GitHub.