gitbutlerapp/gitbutler · error

merge conflict when computing workspace tree

Error message

merge conflict when computing workspace tree

What it means

merge_workspace computes the workspace tree by merging branch heads into the workspace; after performing a merge it checks for unresolved conflicts of the relevant kind. If unresolved conflicts remain when computing the workspace tree, it bails because no single merged tree can be produced.

Solutions

  1. Resolve the underlying git conflicts on the involved branches (checkout, merge manually, or use the UI conflict resolution) and retry
  2. Inspect which files conflict (git status / gitbutler state) and normalize branch contents before the operation
  3. Update/rebase the branch onto the current workspace head so the merge becomes trivial
  4. If state is stale, discard/rebuild workspace state (but status refresh) so merges recompute from clean heads
Defensive patterns

Strategy: try-catch

Validate before calling

// before the operation
let conflicts = repo.check_merge_conflicts(head_a, head_b)?;
if conflicts { /* resolve or warn before calling merge-dependent APIs */ }

Try / catch

match result {
  Err(e) if e.to_string().contains("merge conflict when computing workspace tree") => {
    // enter conflict-resolution flow: list conflicting files, guide user
  }
  r => r?,
}

Prevention

When it happens

Trigger: update_uncommitted_changes_with_tree or move_tree_between_workspaces triggers a merge whose result has_unresolved_conflicts(conflict_kind) == true — i.e. overlapping changes between workspace head and the branch being merged.

Common situations: Two branches touched the same lines/paths; moving files between workspaces where the destination already has conflicting content; stale workspace state after a rebase or manual conflict edit; binary or rename/rename conflicts the merge driver cannot auto-resolve.

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


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/76b2d84b9168ef94. Report an issue: GitHub.

Appendix: source

Thrown at crates/gitbutler-workspace/src/branch_trees.rs:179

        return Ok(*workspace.heads.first().expect("List is length 1"));
    }

    let mut output = workspace.base;
    let base = workspace.base;

    let (merge_options, conflict_kind) = repo.merge_options_fail_fast()?;

    for head in &workspace.heads {
        let mut merge = repo.merge_trees(
            base,
            output,
            *head,
            repo.default_merge_labels(),
            merge_options.clone(),
        )?;

        if merge.has_unresolved_conflicts(conflict_kind) {
            anyhow::bail!("merge conflict when computing workspace tree");
        }
        output = merge.tree.write()?.detach();
    }

    Ok(output)
}

#[cfg(test)]
mod tests {
    use gix::object::tree::EntryKind;

    use super::*;

    fn tree(repo: &gix::Repository, files: &[(&str, &str)]) -> Result<gix::ObjectId> {
        let mut tree = repo.empty_tree().edit()?;
        for (path, contents) in files {
            tree.upsert(
                *path,

View on GitHub (pinned to 58e5313667)