gitbutlerapp/gitbutler · error
Failed to merge bases while cherry picking commit
Error message
Failed to merge bases while cherry picking commit {target}. Encountered a conflict while merging the commit's original bases/new bases. What it means
Cherry-picking a commit requires merging its original merge bases (and 'onto' bases) into the new graph. This error is raised via format_base_merge_error when one of those base merges conflicted, meaning the commit could not be transplanted onto its new parent. The rebase aborts early with a formatted diagnostic describing which merge failed.
Solutions
- Read the formatted error's base_merge_failed/onto_merge_failed detail to identify which commit failed.
- Manually rebase or re-create the failing commit onto the target base, then retry the rebase.
- Reduce the divergence: rebase the source branch onto the target first, or split the stack into smaller rebases.
Defensive patterns
Strategy: try-catch
Try / catch
match rebase_result {
Err(e) if e.to_string().contains("Failed to merge bases while cherry picking") => {
// parse formatted detail, re-create failing commit manually, then retry
}
other => other?,
} Prevention
- Keep stacks small and rebased frequently to limit divergence
- Avoid external history rewrites (force-push/filter-repo) under rebased branches
- Pre-fetch and integrate upstream before running moves/absorbs
When it happens
Trigger: Calling rebase where a Pick step's original base(s) or onto base(s) fail to merge (base_merge_failed or onto_merge_failed set in the CherryPickOutcome::MergeBaseFailed variant).
Common situations: Deeply diverged histories; commits whose parents were rewritten externally (e.g. force-push, filter-repo) so original bases no longer merge; move/absorb operations on heavily edited stacks.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- Cannot merge : merging into / resulted in conflicts. Rebase…
- Commit was marked as not conflictable, but resulted in a…
- Encountered conflict when merging tree
- Failed to merge bases while cherry picking commit
- A matching parent can't be found in the output graph
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/641d39e53a89dfca.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-rebase/src/graph_rebase/rebase.rs:98
| CherryPickOutcome::Identity(new_id) => {
let mut new_pick = pick.clone();
new_pick.id = new_id;
let new_idx = output_graph.add_node(Step::Pick(new_pick));
graph_mapping.insert(step_idx, new_idx);
if !pick.exclude_from_tracking {
history.update_mapping(pick.id, new_id);
}
new_idx
}
CherryPickOutcome::FailedToMergeBases {
base_merge_failed,
bases,
onto_merge_failed,
ontos,
} => {
// Exit early - the rebase failed because it encountered a commit it couldn't pick
bail!(format_base_merge_error(
pick.id,
base_merge_failed,
bases,
onto_merge_failed,
ontos
));
}
}
}
Step::Reference { refname, mutable } => {
// Immutable references are kept in the graph for traversal
// but never moved, created, or deleted.
if mutable {
let graph_parents = collect_ordered_parents(&self.graph, step_idx);
let first_parent_idx = graph_parents
.first()
.context("References should have at least one parent")?;
let Some(new_idx) = graph_mapping.get(first_parent_idx) else {View on GitHub (pinned to 58e5313667)