gitbutlerapp/gitbutler · error
Refusing to land ` `: commit(s) on unnamed segment(s) below…
Error message
Refusing to land `{branch}`: {} commit(s) on unnamed segment(s) below it would also be published to {target_display}. Pass --whole-stack to land `{branch}` together with everything below it. What it means
`validate_branch_landing` refuses to land a branch when it sits on top of commits from unnamed segments below it (segments whose branch refs were deleted but whose commits remain). Landing the branch would also publish those orphaned commits to the target, which without `--whole-stack` is not an allowed partial publish, so the operation is refused with a count of the affected commits.
Solutions
- Pass `--whole-stack` (`but land <branch> --whole-stack`) to explicitly publish everything below together with the branch.
- Restore a named branch on the orphaned lower commits, land that bottom segment first, then land this branch.
- Discard the orphaned lower commits if they are not wanted, then land normally.
Example fix
// before but land feature-2 // refused: 3 commit(s) on unnamed segment(s) below // after but land feature-2 --whole-stack # explicitly includes everything below
Defensive patterns
Strategy: validation
Validate before calling
// detect orphaned commits below the branch before landing without --whole-stack
const ws = await api.workspaceState();
const below = ws.stacks.flatMap(s => s.segments)
.filter(seg => seg.position < positionOf(branch) && !seg.refName);
const orphanCommits = below.reduce((n, seg) => n + seg.commitCount, 0);
if (orphanCommits > 0) throw new Error(`Use --whole-stack or handle ${orphanCommits} orphaned commit(s) below first`); Type guard
null
Try / catch
try {
await api.land(branch);
} catch (e) {
if (String(e).includes('Pass --whole-stack')) {
await api.land(branch, { wholeStack: true }); // or handle orphaned commits first
} else throw e;
} Prevention
- Land bottom-up in a stack so orphaned lower commits never accumulate.
- After deleting lower branch refs, decide explicitly: land (--whole-stack) or discard the commits.
- Review unnamed segments during workspace cleanup sessions.
When it happens
Trigger: Calling `branch_land` without `whole_stack` where `scan.commits_below > 0` and `scan.lower_segments` is empty — the branch is stacked above unnamed segments (deleted refs) whose commits would be implicitly published to `target_display`.
Common situations: Lower branches were deleted with `git branch -D` or via UI without landing, leaving their commits in the stack; rebasing onto a workspace with orphaned commits; inheriting a workspace from a teammate whose refs differ.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Refusing to land ` ` with --whole-stack: it is not the top…
- Cannot land ` `: it would publish conflicted commit ( )…
- Refusing to land ` `: it is stacked on top of other…
- Refusing to land ` ` with --whole-stack: it is not the top…
- Aborting due to empty branch name
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/c6cdd6fad98d4893.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/land/mod.rs:427
// deleted still holds commits that "land the entire stack" would have to include.
if let Some(top) = scan.upper_segments.first() {
bail!(
"Refusing to land `{branch}` with --whole-stack: it is not the top of its stack. \
--whole-stack lands the entire stack; name its top segment `{top}` instead.",
);
}
bail!(
"Refusing to land `{branch}` with --whole-stack: it is not the top of its stack — \
unnamed segment(s) with commits sit above it (their branch refs no longer exist), so \
landing `{branch}` would not land the entire stack.",
);
}
// Key off the commits below, not the segment names: segments whose branch ref was deleted are
// unnamed but their commits would be published all the same.
let publishes_below = scan.commits_below > 0 || !scan.lower_segments.is_empty();
if publishes_below && !whole_stack {
if scan.lower_segments.is_empty() {
bail!(
"Refusing to land `{branch}`: {} commit(s) on unnamed segment(s) below it would \
also be published to {target_display}. Pass --whole-stack to land `{branch}` \
together with everything below it.",
scan.commits_below,
);
}
bail!(
"Refusing to land `{branch}`: it is stacked on top of {} other segment(s) ({}) \
whose commits would also be published to {target_display}. Land the bottom segment \
`{}`, or pass --whole-stack to land `{branch}` together with everything below it.",
scan.lower_segments.len(),
scan.lower_segments.join(", "),
scan.lower_segments.last().expect("non-empty checked above"),
);
}
if !scan.conflicted.is_empty() {
bail!(View on GitHub (pinned to 58e5313667)