{"record":{"id":"2001393df3c4b46b","repo":"GitoxideLabs/gitoxide","slug":"rebasing-would-cause-a-merge-conflict","errorCode":null,"errorMessage":"rebasing would cause a merge conflict","messagePattern":"rebasing would cause a merge conflict","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/rebase.rs","lineNumber":2701,"sourceCode":"    let new_base = parent_tree(repo, new_parents.first().copied())?;\n    if commit.tree == old_base {\n        return Ok(TreeRewrite::Complete(new_base));\n    }\n    if old_base == new_base {\n        return Ok(TreeRewrite::Complete(commit.tree));\n    }\n    cherry_pick_tree_outcome(repo, old_base, new_base, commit.tree)\n}\n\npub(super) fn cherry_pick_tree(\n    repo: &gix::Repository,\n    old_base: ObjectId,\n    new_base: ObjectId,\n    tree: ObjectId,\n) -> Result<ObjectId> {\n    match cherry_pick_tree_outcome(repo, old_base, new_base, tree)? {\n        TreeRewrite::Complete(tree) => Ok(tree),\n        TreeRewrite::Conflict { .. } => anyhow::bail!(\"rebasing would cause a merge conflict\"),\n    }\n}\n\nfn cherry_pick_tree_outcome(\n    repo: &gix::Repository,\n    old_base: ObjectId,\n    new_base: ObjectId,\n    tree: ObjectId,\n) -> Result<TreeRewrite> {\n    if tree == old_base {\n        return Ok(TreeRewrite::Complete(new_base));\n    }\n    if old_base == new_base {\n        return Ok(TreeRewrite::Complete(tree));\n    }\n    let labels = gix::merge::blob::builtin_driver::text::Labels {\n        ancestor: Some(BStr::new(b\"parent\")),\n        current: Some(BStr::new(b\"rebased parent\")),","sourceCodeStart":2683,"sourceCodeEnd":2719,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/rebase.rs#L2683-L2719","documentation":"When cherry-picking a tree change during a rebase, `cherry_pick_tree_outcome` may report `TreeRewrite::Conflict`. `cherry_pick_tree_checked` (this call site) converts that outcome into a hard error because a rebase that would produce merge conflicts cannot proceed automatically.","triggerScenarios":"Calling the rebase/cherry-pick helper with `old_base`, `new_base`, and `tree` ids such that applying the diff between `old_base` and `new_base` onto `tree` results in `TreeRewrite::Conflict { .. }` — the three-way merge is not clean (competing changes to the same paths).","commonSituations":"Rebasing a branch whose commits touch the same lines/files as commits on the new base; reordering commits that conflict with each other; rebasing after upstream force-push changed overlapping content.","solutions":["Resolve the conflict manually: perform the rebase interactively and fix the conflicting files at the conflicting commit.","Rebase onto a different base that does not conflict with the commits being replayed.","Recreate the commit(s) with changes merged against the new base before rebasing.","Use a merge instead of a rebase for histories that genuinely conflict."],"exampleFix":"// before: blind automatic rebase\nlet tree = cherry_pick_tree_checked(repo, old_base, new_base, tree)?; // bails on conflict\n// after: probe the outcome first and handle conflicts\nmatch cherry_pick_tree_outcome(repo, old_base, new_base, tree)? {\n    TreeRewrite::Complete(t) => Ok(t),\n    TreeRewrite::Conflict { .. } => prompt_user_to_resolve_and_retry(),\n}?","handlingStrategy":"try-catch","validationCode":"// probe the merge cleanly before committing to the rebase\nlet clean = matches!(\n    cherry_pick_tree_outcome(repo, old_base, new_base, tree)?,\n    TreeRewrite::Complete(_)\n);\n","typeGuard":null,"tryCatchPattern":"match cherry_pick_tree_checked(repo, old_base, new_base, tree) {\n    Err(e) if e.to_string().contains(\"merge conflict\") => {\n        fall_back_to_interactive_resolution(repo, old_base, new_base)?\n    }\n    other => other,\n}\n","preventionTips":["Rebase frequently to keep branches close to their base","Check for overlapping file changes between branch and new base before rebasing","Prefer interactive rebase with conflict resolution for diverged histories"],"tags":["rebase","merge-conflict","cherry-pick","git"],"backgroundTag":"git-command-failed","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}