gitbutlerapp/gitbutler · error

Tearing off a branch requires a workspace common base

Error message

Tearing off a branch requires a workspace common base

What it means

Tearing off a branch requires the workspace graph to have a common base - a lower-bound segment whose ref the workspace was cut from. The lower_bound_segment_id is missing or the segment has no ref name, so tear_off_branch() cannot determine where the workspace diverged and refuses to proceed.

Solutions

  1. Ensure the workspace was created from a base ref so it has a lower-bound segment
  2. Check the workspace graph for an anonymous lower bound and rebase/recreate the workspace on a named base ref
  3. Use a different operation (e.g. rebase or move) if the workspace lacks a common base

Example fix

// before
let outcome = tear_off_branch(editor, ref_name);
// after
if workspace.lower_bound_segment_id.is_none() {
    anyhow::bail!("workspace has no common base; cannot tear off");
}
let outcome = tear_off_branch(editor, ref_name);
Defensive patterns

Strategy: validation

Validate before calling

if workspace.lower_bound_segment_id
    .map(|id| workspace.graph[id].ref_name().is_none())
    .unwrap_or(true)
{
    // workspace lacks a named common base
}

Try / catch

match tear_off_branch(editor, ref_name) {
    Err(e) if e.to_string().contains("workspace common base") => recreate_workspace_on_named_base(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling tear_off_branch() on a workspace whose lower_bound_segment_id is None, or whose lower-bound graph segment is anonymous (no ref_name), so no common-base reference can be selected in the graph.

Common situations: Workspaces created without a base reference; stacked-branch workspaces whose lower bound segment lost its ref after deletes/rewrites; graphs built from repos where the workspace has no upstream/base ref.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/10fa60ad00f8beac. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-workspace/src/branch/move_branch.rs:111

                ws_meta,
                new_tip: None,
                branch_stack_order: None,
            });
        }

        let Some(workspace_head) = workspace.tip_commit().map(|commit| commit.id) else {
            bail!("Couldn't find workspace head.")
        };
        let head_selector = editor
            .select_commit(workspace_head)
            .context("Failed to find the workspace head in the graph.")?;

        let Some(lower_bound_ref) = workspace
            .lower_bound_segment_id
            .map(|segment_id| &workspace.graph[segment_id])
            .and_then(|segment| segment.ref_name())
        else {
            bail!("Tearing off a branch requires a workspace common base");
        };

        let target_selector = editor
            .select_reference(lower_bound_ref)
            .context("Failed to find target reference in graph.")?;

        let DisconnectParameters {
            delimiter: subject_delimiter,
            children_to_disconnect,
            parents_to_disconnect,
        } = get_disconnect_parameters(
            &editor,
            source_stack,
            subject_segment,
            Some(workspace_head),
        )?;

        editor.disconnect_segment_from(

View on GitHub (pinned to 58e5313667)