{"record":{"id":"176883324a12c632","repo":"gitbutlerapp/gitbutler","slug":"moving-branches-currently-need-a-workspace-commit","errorCode":null,"errorMessage":"Moving branches currently need a workspace commit","messagePattern":"Moving branches currently need a workspace commit","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/move_branch.rs","lineNumber":78,"sourceCode":"        subject_branch_name: &FullNameRef,\n        stack_id_override: Option<StackId>,\n    ) -> anyhow::Result<Outcome<'ws, 'meta, M>> {\n        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            });","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/move_branch.rs#L60-L96","documentation":"`tear_off_branch` only supports workspaces of kind `Managed`; when `workspace.kind` is `ManagedMissingWorkspaceCommit` (the workspace commit is missing — e.g. the workspace ref/commit was deleted or lost but managed metadata remains) it bails with this message. It is an explicit first-iteration scope limit (see the TODO in the source) rather than a corruption error.","triggerScenarios":"Invoking move-branch in a repository whose workspace lost its workspace commit: the `refs/namespace` workspace ref or workspace commit object was removed (manual cleanup, partial clone, interrupted operation) while stack metadata still classifies it as managed.","commonSituations":"After a failed/interrupted workspace operation, `git gc` pruning, users deleting GitButler refs by hand, or version migrations that drop the workspace commit. The app otherwise may look usable, but branch move refuses.","solutions":["Restore or recreate the workspace commit (re-open the project so GitButler can re-establish the workspace, or use its repair/recovery flow), then retry the move.","As a fallback, recreate the workspace (unadopt/re-adopt) so kind returns to `Managed`.","Check `workspace.kind` before calling move-branch and disable the UI action for this state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if !matches!(workspace.kind, but_graph::WorkspaceKind::Managed { .. }) {\n    anyhow::bail!(\"branch move requires a healthy managed workspace (current kind: {:?}); repair the workspace commit first\", workspace.kind);\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(\"need a workspace commit\") {\n        // route user to workspace repair / re-adoption flow\n    }\n}","preventionTips":["Gate the move-branch action on workspace.kind == Managed in the UI.","After losing the workspace commit (manual ref deletion, gc), repair before using stack operations."],"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"}