{"record":{"id":"e4a9baa867340634","repo":"gitbutlerapp/gitbutler","slug":"moving-a-non-empty-branch-in-single-branch-mode-is","errorCode":null,"errorMessage":"Moving a non-empty branch in single-branch mode is not yet supported","messagePattern":"Moving a non-empty branch in single-branch mode is not yet supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/move_branch.rs","lineNumber":244,"sourceCode":"    /// The reordered chain is returned in [`Outcome::branch_stack_order`] for the caller to persist\n    /// (via [`RefMetadata::set_branch_stack_order`]) rather than being written here, so callers can\n    /// skip persistence for dry-run previews.\n    fn move_branch_in_single_branch_mode<'ws, 'meta, M: RefMetadata>(\n        mut successful_rebase: SuccessfulRebase<'ws, 'meta, M>,\n        workspace: but_graph::Workspace,\n        source: WorkspaceSegmentContext,\n        destination: WorkspaceSegmentContext,\n        subject_branch_name: &FullNameRef,\n        target_branch_name: &FullNameRef,\n    ) -> anyhow::Result<Outcome<'ws, 'meta, M>> {\n        let (source_stack, subject_segment) = &source;\n        let (destination_stack, _) = &destination;\n        let entrypoint = workspace.ref_name().map(ToOwned::to_owned);\n        // A branch that owns commits can only be reordered within its current stack in\n        // single-branch mode. Moving it across stacks would change commit ownership and needs a\n        // real rebase.\n        if !subject_segment.commits.is_empty() && !same_stack(source_stack, destination_stack) {\n            bail!(\"Moving a non-empty branch in single-branch mode is not yet supported\");\n        }\n        // Reordering same-target empty refs only changes which empty segment is displayed first.\n        // If their targets differ, however, the subject crosses commit-owning segments and its ref\n        // must move with it or those commits would be projected as belonging to the empty branch.\n        let move_requires_graph_update = !subject_segment.commits.is_empty()\n            || successful_rebase.reference_target(subject_branch_name)?\n                != successful_rebase.reference_target(target_branch_name)?;\n        let existing_order = {\n            let (_repo, meta) = successful_rebase.repo_and_meta_mut();\n            if !meta.can_persist_branch_stack_order() {\n                bail!(\n                    \"Cannot reorder '{subject_branch_name}' in single-branch mode without branch order metadata\"\n                );\n            }\n            // Reorder against the existing chain. A movable subject is always part of `branch_order`\n            // (that's what makes it a projected segment), so the first lookup normally succeeds. The\n            // target and entrypoint lookups are defensive fallbacks so that, should the projection ever\n            // surface a segment that isn't tracked yet, we extend the real chain instead of clobbering","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/move_branch.rs#L226-L262","documentation":"In single-branch mode, move_branch_in_single_branch_mode can only reorder empty branch refs (pure display ordering). A branch that owns commits cannot be moved across stacks because that would change commit ownership and require a real rebase, which single-branch mode does not support - so it bails.","triggerScenarios":"Calling move_branch() while the workspace is in single-branch mode, where the subject branch has commits and the source and destination stacks differ (cross-stack move).","commonSituations":"Users trying to reorder/re-parent a non-empty branch between stacks while in single-branch (no workspace commit) mode; drag-and-drop of a commit-owning branch to a different stack in the UI.","solutions":["Enable managed multi-branch mode so the move can be performed with a real rebase","Move the branch within its current stack only (same_stack moves are allowed)","Rebase manually or use a different operation that supports commit ownership changes"],"exampleFix":"// before\nmove_branch(editor, subject, target) // subject has commits, cross-stack\n// after\n// enable managed workspace mode first, or keep target in the same stack\nassert!(same_stack(source_stack, destination_stack));\nmove_branch(editor, subject, target)","handlingStrategy":"validation","validationCode":"// in single-branch mode, only same-stack moves of commit-owning branches are allowed\nif !subject_segment.commits.is_empty() && !same_stack(source_stack, dest_stack) {\n    // cross-stack move of a non-empty branch: unsupported\n}","typeGuard":null,"tryCatchPattern":"match move_branch(editor, subject, target) {\n    Err(e) if e.to_string().contains(\"single-branch mode is not yet supported\") => switch_to_managed_mode_and_retry(),\n    other => other?,\n}","preventionTips":["Restrict single-branch-mode moves to empty branches or same-stack reorders","Switch to managed multi-branch mode before cross-stack moves","Check whether the subject branch owns commits before initiating a move"],"tags":["git","workspace","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}