gitbutlerapp/gitbutler · error

Branch '{}' not found. Available branches: {}

Error message

Branch '{}' not found. Available branches:
{}

What it means

`resolve_branch_name` first parses the argument against the workspace IdMap; when nothing matches it falls back to a literal branch name, but requires it to appear in `get_available_branch_names`, which enumerates branches of applied stacks. So the error means: not a known CLI id, and not a branch of any applied stack — a branch that exists only as a plain Git ref does not qualify.

Source

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

        flags.push(but_gerrit::PushFlag::Private);
    }

    Ok(flags)
}

fn resolve_branch_name(
    ctx: &mut Context,
    id_map: &IdMap,
    branch_id: &str,
) -> anyhow::Result<String> {
    // Try to resolve as CliId first
    let cli_ids = id_map.parse_using_context(branch_id, ctx)?;

    if cli_ids.is_empty() {
        // If no CliId matches, treat as literal branch name but validate it exists
        let available_branches = get_available_branch_names(ctx)?;
        if !available_branches.contains(&branch_id.to_string()) {
            return Err(anyhow::anyhow!(
                "Branch '{}' not found. Available branches:\n{}",
                branch_id,
                format_branch_suggestions(&available_branches)
            ));
        }
        return Ok(branch_id.to_string());
    }

    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() {

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Read the 'Available branches' list the error prints and copy the exact name
  2. If the branch's stack is unapplied, apply it first so it becomes selectable
  3. If it is a plain Git branch, push it with `git push` or bring it into the workspace
  4. Check `but status` to see which stacks and branches are currently applied

Example fix

# before
but push feaure-x
# error: Branch 'feaure-x' not found. Available branches: ...

# after
but push feature-x   # exact name from the printed suggestion list
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the branch is in an applied stack before pushing
but status | grep -F "$branch" || echo "branch '$branch' not in an applied stack" >&2

Try / catch

// Parse the suggestion list out of the failure to offer corrections
let out = Command::new("but").args(["push", name]).output()?;
let err = String::from_utf8_lossy(&out.stderr).to_string();
if err.contains("not found. Available branches:") {
    let list: Vec<&str> = err.lines().skip_while(|l| !l.contains("Available")).skip(1).collect();
    // present `list` to the user as candidates
}

Prevention

When it happens

Trigger: Running `but push <name>` with a typo, with a branch whose stack is currently unapplied, or with a regular Git branch that was never brought into the GitButler workspace.

Common situations: Autocomplete offering raw git branches instead of workspace branches; stack unapplied or archived before pushing; branch created outside the workspace with plain `git checkout -b`.

Related errors


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