gitbutlerapp/gitbutler · error
No merge-base found for revisions
Error message
No merge-base found for revisions: {} What it means
`but debug revision merge-base` computes the merge-base of the given revisions using a commit graph. If the graph yields no common ancestor (None), this error bails with the joined revision list. It signals that the queried revisions share no merge-base, or the graph could not be built to find one.
Solutions
- Verify each revision exists: git rev-parse --verify <rev> for every argument
- Check the revisions actually share history: git merge-base <a> <b>; if not, use --allow-unrelated-histories workflows or pass an ancestor commit
- Ensure the repository has at least two commits with a common root before running the command
Example fix
// before but debug revision merge-base main orphan-branch // after git merge-base main orphan-branch # confirm a base exists first but debug revision merge-base main feature-branch
Defensive patterns
Strategy: validation
Validate before calling
for rev in revisions {
let ok = std::process::Command::new("git")
.args(["rev-parse", "--verify", rev])
.output()
.map(|o| o.status.success());
if !ok.unwrap_or(false) { return Err(format!("unknown revision: {rev}")); }
} Try / catch
match merge_base {
Ok(base) => println!("{base}"),
Err(e) if e.to_string().contains("No merge-base found") => {
eprintln!("revisions share no common ancestor; check histories");
}
Err(e) => return Err(e),
} Prevention
- Verify all revisions resolve with git rev-parse before invoking
- Confirm the branches share a root with git merge-base first
- Avoid merge-base queries on orphan/unrelated histories
When it happens
Trigger: Running the merge-base command with revisions that have no common ancestor (e.g. unrelated histories, empty repo, or a single/zero revision set), or the octopus merge-base computation from the graph returns None.
Common situations: Comparing branches created with --orphan or from unrelated roots; typo'd revision names resolving to disjoint commits; running on a freshly initialized repository with no commits.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Aborting due to empty branch name
- Bare repositories are not supported.
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch " " has no conflicted commits.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/cbfc09124feca2f7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-debug/src/command/revision.rs:139
.entered();
graph
.find_merge_base_octopus(segments)
.map(|segment_id| {
graph
.tip_skip_empty(segment_id)
.map(|commit| commit.id)
.with_context(|| {
format!(
"BUG: Segment {segment_id:?} does not contain a reachable tip commit"
)
})
})
.transpose()
.context("Failed to compute octopus merge-base from graph")?
};
let Some(merge_base) = merge_base else {
bail!(
"No merge-base found for revisions: {}",
merge_base_args.revisions.join(", ")
);
};
writeln!(out, "{merge_base}")?;
Ok(())
}
fn args_to_tips(repo: &gix::Repository, graph_args: &RevisionGraphArgs) -> Result<Vec<Tip>> {
let mut tips = Vec::new();
if let Some(tip) = graph_args
.target_ref
.as_deref()
.map(|target_ref| {
let mut reference = repo
.find_reference(target_ref)View on GitHub (pinned to 58e5313667)