{"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":null,"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/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/move_branch.rs#L63-L99","documentation":"tear_off_branch only supports Managed workspaces; AdHoc (non-managed) workspaces are explicitly unsupported for branch moves because the imperative move logic depends on managed workspace invariants. The code comments note this is a deliberate scope limit of the first iteration.","triggerScenarios":"Calling tear_off_branch when workspace.kind is WorkspaceKind::AdHoc — i.e. the target workspace was created ad hoc rather than through the managed workspace flow.","commonSituations":"Operating on a plain git repository or a workspace created outside GitButler's managed flow; users pointing the API at a non-managed worktree.","solutions":["Move the branch manually with git (`git branch`, `git cherry-pick`/rebase) since the API won't handle ad-hoc workspaces","Convert the repository/worktree into a managed workspace before using tear_off_branch","Wait for/exercise future library support for moving branches in non-managed workspaces"],"exampleFix":"// before\nmove_branch.tear_off_branch(...)?; // ad-hoc workspace -> error\n// after\nif workspace.kind.is_managed() {\n    move_branch.tear_off_branch(...)?;\n} else {\n    // fall back to plain git operations\n}","handlingStrategy":"validation","validationCode":"fn is_managed(workspace: &Workspace) -> bool {\n    matches!(workspace.kind, WorkspaceKind::Managed { .. })\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"non-managed workspaces\") => {\n        eprintln!(\"falling back to plain git branch move\");\n        move_with_git(subject_branch_name)?;\n        Ok(())\n    }\n    other => other,\n}","preventionTips":["Only call tear_off_branch on workspaces created via the managed flow","Inspect workspace.kind (AdHoc vs Managed) before branch operations","Use plain git tooling for ad-hoc worktrees"],"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"}