gitbutlerapp/gitbutler · warning

No branches selected. Aborting.

Error message

No branches selected. Aborting.

What it means

In the `but forge review` publish path, once branches without reviews are collected, an interactive multi-select (`prompt_multi_select("Select branches to publish", ...)`) is shown. A `None` return from that prompt — a cancelled picker, not a confirmed empty selection — is converted via `ok_or_else` into this error, so nothing gets published.

Source

Thrown at crates/but/src/command/legacy/forge/review.rs:610

                ),
                branch.name.clone(),
            ));
        }
    }

    let Some(branch_options) = nonempty::NonEmpty::from_vec(branch_options) else {
        if let Some(out) = out.for_human() {
            writeln!(out, "No branches available to publish.")?;
        }
        return Ok(vec![]);
    };

    let mut input = out
        .prepare_for_terminal_input()
        .context("Terminal input not available. Please specify branches to publish using command line arguments.")?;
    let selected_branches = input
        .prompt_multi_select("Select branches to publish", &branch_options)?
        .ok_or_else(|| anyhow::anyhow!("No branches selected. Aborting."))?
        .into_iter()
        .cloned()
        .collect();

    Ok(selected_branches)
}

#[expect(clippy::too_many_arguments)]
async fn publish_reviews_for_branch_and_dependents(
    ctx: &mut Context,
    branch_name: &str,
    review_map: &std::collections::HashMap<String, Vec<but_forge::ForgeReview>>,
    stack_entry: &HeadInfoStack,
    skip_force_push_protection: bool,
    with_force: bool,
    run_hooks: bool,
    default_message: bool,
    draft: bool,

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Re-run and confirm at least one branch: Space to toggle, Enter to accept
  2. Pass the branches to publish as command-line arguments so no picker opens (see `but forge review --help` for the argument form)
  3. Treat the abort as a clean no-op — no branches were published

Example fix

# before
but forge review --publish
# (cancel the multi-select with Esc)
# error: No branches selected. Aborting.

# after
but forge review --publish   # select with Space, confirm with Enter
# or name branches on the command line to skip the picker
Defensive patterns

Strategy: fallback

Validate before calling

# Script-safe: avoid the interactive picker by passing branch arguments
# (the picker only appears when no branches are given; see but forge review --help)
but forge review --publish <branch>

Try / catch

# Cancellation is a no-op, not a failure — map it to exit 0 in wrappers
stderr=$(but forge review --publish 2>&1 >/dev/null) || {
  [[ "$stderr" == *"No branches selected"* ]] && exit 0   # cancelled on purpose
  echo "$stderr" >&2; exit 1
}

Prevention

When it happens

Trigger: Running the publish flow without branch arguments in a terminal and pressing Esc/Ctrl-C at the 'Select branches to publish' multi-select; `prompt_multi_select` returns None and the `ok_or_else` arm fires.

Common situations: User opens the picker to look around and backs out; SSH session drops or terminal closes mid-prompt; muscle memory from tools where Esc means 'accept default'.

Related errors


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