gitbutlerapp/gitbutler · error
Moving branches in non-managed workspaces is not supported
Error message
Moving branches in non-managed workspaces is not supported
What it means
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.
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
Example fix
// before
move_branch.tear_off_branch(...)?; // ad-hoc workspace -> error
// after
if workspace.kind.is_managed() {
move_branch.tear_off_branch(...)?;
} else {
// fall back to plain git operations
} Defensive patterns
Strategy: validation
Validate before calling
fn is_managed(workspace: &Workspace) -> bool {
matches!(workspace.kind, WorkspaceKind::Managed { .. })
} Try / catch
match result {
Err(e) if e.to_string().contains("non-managed workspaces") => {
eprintln!("falling back to plain git branch move");
move_with_git(subject_branch_name)?;
Ok(())
}
other => other,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Operating on a plain git repository or a workspace created outside GitButler's managed flow; users pointing the API at a non-managed worktree.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Moving a non-empty branch in single-branch mode is not yet…
- Ad-hoc (single-branch) branch moves are not supported…
- Bare repositories are not supported.
- Branch ' ' cannot be created: the target commit ( ) already…
- BranchNotFound
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/60922a9c076a9f8f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/move_branch.rs:81
let successful_rebase = editor.rebase()?;
let workspace = successful_rebase.overlayed_graph()?.into_workspace()?;
let mut editor = successful_rebase.into_editor();
let Some(source) = workspace.find_segment_and_stack_by_refname(subject_branch_name) else {
bail!(
"Couldn't find branch to move in workspace with reference name: {subject_branch_name}"
);
};
// We're currently stopping the move branch operations imperatively at this stage, in order to
// reduce the scope of this first iteration of moving the branches.
// TODO: Enable and test that we can move branches in any kind of workspace.
match &workspace.kind {
WorkspaceKind::Managed { .. } => {}
WorkspaceKind::ManagedMissingWorkspaceCommit { .. } => {
bail!("Moving branches currently need a workspace commit")
}
WorkspaceKind::AdHoc => {
bail!("Moving branches in non-managed workspaces is not supported");
}
};
let mut ws_meta = workspace.metadata.clone();
let (source_stack, subject_segment) = source;
if source_stack.segments.len() == 1 {
// There's only one branch in the source stack. Nothing to do.
return Ok(Outcome {
rebase: editor.rebase()?,
ws_meta,
new_tip: None,
branch_stack_order: None,
});
}
let Some(workspace_head) = workspace.tip_commit().map(|commit| commit.id) else {View on GitHub (pinned to 58e5313667)