{"record":{"id":"cfb2127db11b4bc5","repo":"affaan-m/ECC","slug":"git-rebase-failed","errorCode":null,"errorMessage":"git rebase failed: {}{}","messagePattern":"git rebase failed: (.+?)(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/worktree/mod.rs","lineNumber":950,"sourceCode":"            .arg(\"-C\")\n            .arg(&worktree.path)\n            .args([\"rebase\", \"--abort\"])\n            .output()\n            .context(\"Failed to abort unsuccessful rebase\")?;\n        let abort_warning = if abort_output.status.success() {\n            String::new()\n        } else {\n            format!(\n                \" (rebase abort warning: {})\",\n                String::from_utf8_lossy(&abort_output.stderr).trim()\n            )\n        };\n        let stderr = format!(\n            \"{}\\n{}\",\n            String::from_utf8_lossy(&output.stdout),\n            String::from_utf8_lossy(&output.stderr)\n        );\n        anyhow::bail!(\"git rebase failed: {}{}\", stderr.trim(), abort_warning);\n    }\n\n    let after_head = branch_head_oid_in_repo(&repo_root, &worktree.branch)?;\n    let rebase_output = format!(\n        \"{}\\n{}\",\n        String::from_utf8_lossy(&output.stdout),\n        String::from_utf8_lossy(&output.stderr)\n    );\n\n    Ok(RebaseOutcome {\n        branch: worktree.branch.clone(),\n        base_branch: worktree.base_branch.clone(),\n        already_up_to_date: before_head == after_head || rebase_output.contains(\"up to date\"),\n    })\n}\n\npub fn branch_head_oid(worktree: &WorktreeInfo, branch: &str) -> Result<String> {\n    let repo_root = base_checkout_path(worktree)?;","sourceCodeStart":932,"sourceCodeEnd":968,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/worktree/mod.rs#L932-L968","documentation":"Raised by `rebase_onto_base` when `git rebase` onto the base branch exits non-zero. The message combines git's stdout and stderr plus an `abort_warning`, since the library aborts the failed rebase before surfacing it — most commonly this is a rebase conflict that could not be resolved automatically.","triggerScenarios":"Calling rebase_onto_base when the branch's commits conflict with the new base commits, a commit becomes empty during replay, or the rebase command itself fails (bad ref, detached state).","commonSituations":"Base branch advanced with overlapping changes; pick conflicts on generated files; empty commits after an earlier squash; rebase interrupted by an external process.","solutions":["Read stdout/stderr in the message to find the conflicting commit; resolve manually with 'git rebase --continue' after fixing, or accept the library's auto-abort","Rebase manually in the worktree: 'git rebase <base>', resolve conflicts per commit, then retry the tool","If a commit is now empty, use 'git rebase --skip' or drop it from history","Avoid repeated conflicts by squash-merging branch work back to base regularly","If abort_warning indicates the rebase was aborted, verify with 'git status' that the branch is back at its pre-rebase HEAD before retrying"],"exampleFix":"// before: conflict fails silently until rebase_onto_base bails\nrebase_onto_base(&wt)?;\n// after: pre-check overlap\nlet overlap = Command::new(\"git\")\n    .args([\"merge-tree\", \"--write-tree\", &base, &wt.branch])\n    .output()?;\nanyhow::ensure!(overlap.status.success(), \"rebase would conflict; resolve manually\");","handlingStrategy":"try-catch","validationCode":"let check = Command::new(\"git\")\n    .args([\"merge-tree\", \"--write-tree\", &base, &wt.branch])\n    .current_dir(&wt.path)\n    .output()?;\nlet rebase_clean = check.status.success();","typeGuard":"fn was_rebase_aborted(err: &anyhow::Error) -> bool {\n    err.to_string().contains(\"aborted\") || err.to_string().contains(\"CONFLICT\")\n}","tryCatchPattern":"match rebase_onto_base(&wt) {\n    Ok(o) => o,\n    Err(e) => {\n        // library auto-aborts; verify branch is intact before retry\n        let head = branch_head_oid_in_repo(&root, &wt.branch)?;\n        eprintln!(\"rebase failed, branch {} at {}\", wt.branch, head);\n        Err(e)\n    }\n}","preventionTips":["Rebase early and often against the base branch","Squash noisy WIP commits to reduce per-commit conflict surface","Verify clean status before rebasing (see error 1431)","Pre-test with 'git merge-tree' before scripted rebases"],"tags":["git","rebase","conflict"],"backgroundTag":"git-command-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}