{"record":{"id":"0667d9a47d5c7769","repo":"gitbutlerapp/gitbutler","slug":"encountered-conflict-when-merging-tree-tree-to-me","errorCode":null,"errorMessage":"Encountered conflict when merging tree {tree_to_merge}{details}","messagePattern":"Encountered conflict when merging tree (.+?)(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-rebase/src/merge.rs","lineNumber":72,"sourceCode":"            Ok(but_core::Commit::from_id(commit_id.attach(repo))?\n                .tree_id_or_kind(TreeKind::Theirs)?\n                .detach())\n        })\n        .collect::<Result<Vec<_>, _>>()?\n        .into_iter();\n    let mut ours = trees_to_merge.next().expect(\"two or more trees\");\n    let (merge_options, unresolved) = repo.merge_options_fail_fast()?;\n    let mut successfully_merged = vec![ours];\n    for tree_to_merge in trees_to_merge {\n        let mut merge = repo.merge_trees(\n            merge_base,\n            ours,\n            tree_to_merge,\n            repo.default_merge_labels(),\n            merge_options.clone(),\n        )?;\n        if merge.has_unresolved_conflicts(unresolved) {\n            return Err(anyhow!(\n                \"Encountered conflict when merging tree {tree_to_merge}{details}\",\n                details = merge_conflict_details(&successfully_merged)\n            )\n            .context(ConflictErrorContext {\n                paths: merge\n                    .conflicts\n                    .iter()\n                    .map(|c| c.ours.location().to_owned())\n                    .collect(),\n            }));\n        }\n        successfully_merged.push(tree_to_merge);\n        ours = merge.tree.write()?.detach();\n    }\n    target_merge_commit.tree = ours;\n    if but_core::commit::Headers::try_from_commit(&target_merge_commit).is_none() {\n        let headers = but_core::commit::Headers::from_config(&repo.config_snapshot());\n        headers.set_in_commit(&mut target_merge_commit);","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-rebase/src/merge.rs#L54-L90","documentation":"Thrown by the octopus (multi-parent) merge path in but-rebase when a tree-level merge leaves unresolved conflicts. The library merges a tree into the current one via gix's merge machinery and, if `merge.has_unresolved_conflicts` is true, aborts with this message plus the conflict details and a ConflictErrorContext carrying the conflicted paths.","triggerScenarios":"Calling the octopus merge routine when the tree being merged (`tree_to_merge`) modifies the same paths as the current tree in incompatible ways, so the recursive/resolve merge produces conflicts instead of a clean tree.","commonSituations":"Rebasing or stacking commits where two branches touched the same lines or same file (add/add conflicts, rename conflicts); applying a workspace merge over divergent edits; automating branch combination where a human would normally resolve manually.","solutions":["Inspect the conflicted paths from the attached ConflictErrorContext and resolve those files manually, then retry the operation","Check out one of the branches and resolve/rebase it first so the trees no longer conflict before the octopus merge","Use merge options (e.g. favor-ours/theirs strategies available via merge_options) to auto-resolve in favor of one side","Split the merge into sequential two-way merges so each conflict can be resolved incrementally"],"exampleFix":"// before\nlet merged = rebase.octopus_merge(&[tree_a, tree_b])?; // panics on conflict\n// after\nmatch rebase.octopus_merge(&[tree_a, tree_b]) {\n    Ok(m) => m,\n    Err(e) if e.downcast_ref::<ConflictErrorContext>().is_some() => {\n        let ctx = e.downcast_ref::<ConflictErrorContext>().unwrap();\n        resolve_paths_manually(&ctx.paths);\n        rebase.octopus_merge(&[tree_a, tree_b])?\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"try-catch","validationCode":"// pre-check for overlapping changes between trees\nlet conflicts = gix::merge::tree::conflicts(&base, &ours, &tree_to_merge)?;\nif !conflicts.is_empty() { resolve_or_warn(&conflicts); }","typeGuard":"fn has_conflict_ctx(e: &anyhow::Error) -> bool {\n    e.downcast_ref::<ConflictErrorContext>().is_some()\n}","tryCatchPattern":"match merge_result {\n    Err(e) if has_conflict_ctx(&e) => {\n        let ctx = e.downcast_ref::<ConflictErrorContext>().unwrap();\n        eprintln!(\"resolve these paths: {:?}\", ctx.paths);\n    }\n    Err(e) => return Err(e),\n    Ok(m) => m,\n}","preventionTips":["Rebase divergent branches before combining them in an octopus merge","Use merge options with a favor-ours/favor-theirs strategy for auto-resolvable overlaps","Surface conflicted paths to users instead of silently merging","Keep stacks small so conflicts stay localized"],"tags":["git","merge-conflict","rebase"],"backgroundTag":"git-command-failed","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"}