{"record":{"id":"abc17d544133900c","repo":"gitbutlerapp/gitbutler","slug":"branch-cannot-be-created-the-target-commit","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/create_reference.rs","lineNumber":484,"sourceCode":"        };\n\n        let updated_workspace = graph_with_new_ref.into_workspace()?;\n        let has_new_ref_as_standalone_segment = updated_workspace\n            .find_segment_and_stack_by_refname(ref_name)\n            .is_some();\n        let existing_ref_is_in_workspace = existing_ref_target_in_workspace.is_some();\n        if !has_new_ref_as_standalone_segment {\n            if existing_ref_target_id.is_some()\n                && !existing_ref_is_in_workspace\n                && !workspace.refname_is_segment(ref_name)\n                && workspace.ref_name() != Some(ref_name)\n            {\n                bail_precondition!(\n                    \"Reference '{}' already exists and is outside the workspace\",\n                    ref_name.shorten()\n                );\n            }\n            bail!(\n                \"Branch '{}' cannot be created: the target commit ({}) already \\\n                 belongs to another branch in the workspace. Each commit can only \\\n                 belong to one branch at a time.\",\n                ref_name.shorten(),\n                ref_target_id,\n            )\n        }\n\n        // Actually apply the changes\n        repo.reference(\n            ref_name,\n            ref_target_id,\n            PreviousValue::ExistingMustMatch(gix::refs::Target::Object(ref_target_id)),\n            \"Dependent branch by GitButler\",\n        )\n        .map_err(|err| {\n            if is_not_a_directory_ref_edit_error(&err)\n                && let Ok(Some(colliding_ref)) = find_colliding_ref_ancestor(repo, ref_name)","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/create_reference.rs#L466-L502","documentation":"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.","triggerScenarios":"Thrown at crates/but-workspace/src/branch/create_reference.rs:484 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}