{"record":{"id":"60922a9c076a9f8f","repo":"gitbutlerapp/gitbutler","slug":"moving-branches-in-non-managed-workspaces-is-not-s","errorCode":null,"errorMessage":"Moving branches in non-managed workspaces is not supported","messagePattern":"Moving branches in non-managed workspaces is not supported","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/move_branch.rs","lineNumber":81,"sourceCode":"        let successful_rebase = editor.rebase()?;\n        let workspace = successful_rebase.overlayed_graph()?.into_workspace()?;\n        let mut editor = successful_rebase.into_editor();\n        let Some(source) = workspace.find_segment_and_stack_by_refname(subject_branch_name) else {\n            bail!(\n                \"Couldn't find branch to move in workspace with reference name: {subject_branch_name}\"\n            );\n        };\n\n        // We're currently stopping the move branch operations imperatively at this stage, in order to\n        // reduce the scope of this first iteration of moving the branches.\n        // TODO: Enable and test that we can move branches in any kind of workspace.\n        match &workspace.kind {\n            WorkspaceKind::Managed { .. } => {}\n            WorkspaceKind::ManagedMissingWorkspaceCommit { .. } => {\n                bail!(\"Moving branches currently need a workspace commit\")\n            }\n            WorkspaceKind::AdHoc => {\n                bail!(\"Moving branches in non-managed workspaces is not supported\");\n            }\n        };\n\n        let mut ws_meta = workspace.metadata.clone();\n\n        let (source_stack, subject_segment) = source;\n\n        if source_stack.segments.len() == 1 {\n            // There's only one branch in the source stack. Nothing to do.\n            return Ok(Outcome {\n                rebase: editor.rebase()?,\n                ws_meta,\n                new_tip: None,\n                branch_stack_order: None,\n            });\n        }\n\n        let Some(workspace_head) = workspace.tip_commit().map(|commit| commit.id) else {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/move_branch.rs#L63-L99","documentation":"`tear_off_branch` bails when `workspace.kind` is `AdHoc` — the repository is being used without a managed GitButler workspace (plain git usage mode). Moving branches between stacks is only defined for managed workspaces, where stacks and the workspace commit exist.","triggerScenarios":"Calling move-branch on a repo that GitButler tracks ad-hoc (no workspace commit/stacks created), e.g. a freshly opened project where the user never created a managed workspace, or after abandoning the workspace.","commonSituations":"Integrating the move API into a tool that runs against arbitrary repos without checking adoption state; users who opened a repo but never set up GitButler branching.","solutions":["Guard the call: only offer branch move when `matches!(workspace.kind, WorkspaceKind::Managed { .. })`.","If the user wants managed features, create/adopt a workspace first, then retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if matches!(workspace.kind, but_graph::WorkspaceKind::AdHoc) {\n    anyhow::bail!(\"repo is used ad-hoc (no managed workspace); create/adopt a workspace before moving branches\");\n}","typeGuard":"fn workspace_supports_branch_move(kind: &but_graph::WorkspaceKind) -> bool {\n    matches!(kind, but_graph::WorkspaceKind::Managed { .. })\n}","tryCatchPattern":"if let Err(err) = move_branch::tear_off_branch(editor, &branch, None) {\n    if err.to_string().contains(\"non-managed workspaces\") {\n        // offer to set up a managed workspace, or hide the feature for this repo\n    }\n}","preventionTips":["Only expose managed-workspace features (branch move) after workspace adoption.","Check workspace.kind once at feature-init and cache the capability flag."],"tags":["rust","git","but-workspace","move-branch","workspace-state","unsupported-operation"],"backgroundTag":"workspace-state-precondition","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}