gitbutlerapp/gitbutler · error · anyhow::Error
Branch '{}' cannot be created: the target commit ({}) alread
Error message
Branch '{}' cannot be created: the target commit ({}) already belongs to another branch in the workspace. Each commit can only belong to one branch at a time. What it means
Error "Branch '{}' cannot be created: the target commit ({}) already belongs to another branch in the workspace. Each commit can only belong to one branch at a time." thrown in gitbutlerapp/gitbutler.
Source
Thrown at crates/but-workspace/src/branch/create_reference.rs:484
};
let updated_workspace = graph_with_new_ref.into_workspace()?;
let has_new_ref_as_standalone_segment = updated_workspace
.find_segment_and_stack_by_refname(ref_name)
.is_some();
let existing_ref_is_in_workspace = existing_ref_target_in_workspace.is_some();
if !has_new_ref_as_standalone_segment {
if existing_ref_target_id.is_some()
&& !existing_ref_is_in_workspace
&& !workspace.refname_is_segment(ref_name)
&& workspace.ref_name() != Some(ref_name)
{
bail_precondition!(
"Reference '{}' already exists and is outside the workspace",
ref_name.shorten()
);
}
bail!(
"Branch '{}' cannot be created: the target commit ({}) already \
belongs to another branch in the workspace. Each commit can only \
belong to one branch at a time.",
ref_name.shorten(),
ref_target_id,
)
}
// Actually apply the changes
repo.reference(
ref_name,
ref_target_id,
PreviousValue::ExistingMustMatch(gix::refs::Target::Object(ref_target_id)),
"Dependent branch by GitButler",
)
.map_err(|err| {
if is_not_a_directory_ref_edit_error(&err)
&& let Ok(Some(colliding_ref)) = find_colliding_ref_ancestor(repo, ref_name)View on GitHub (pinned to caf1f223d3)
When it happens
Trigger: Thrown at crates/but-workspace/src/branch/create_reference.rs:484 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/abc17d544133900c.
Report an issue: GitHub.