Why it matters: read this before resolving squash-merge conflicts on stacked branches with a strategy option.

Context

A branch was built on a dependency PR’s original commits. When that dependency landed on main as a squash commit, the branch conflicted with main, because both sides had changed the same lines. git merge -X ours origin/main looked safe, since the branch already contained the dependency.

Documented

  • Documented: with -X ours, the ort strategy resolves conflicting hunks cleanly and automatically by taking our version, so no conflict markers are left. Only changes from the other tree that don’t conflict with our side end up in the result. (git-merge)

Observed

Seen in one case. The docs don’t cover it.

  • -X ours also applied to hunks where an unrelated PR, squashed into main in the meantime, had edited the same method. That PR’s change vanished with no conflict marker, and the build still passed.
  • It was caught only by diffing the merge result against a previously tested integration tree, then inspecting the hunks in the files both trees changed.
  • What worked: a plain git merge, resolving each hunk by hand and picking the side per hunk, then checking the result against the known-good tree.
Terminal window
git merge origin/main # no -X ours; resolve each hunk by hand
git diff --name-only HEAD <integration-branch> # files that differ from the known-good tree
git diff HEAD <integration-branch> -- <shared-file> # inspect their hunks