How does a three-way merge determine the merge base, and why is it needed?

Last updated 6 July 2026

  • Git walks the commit graph to find the merge base: the lowest common ancestor of both tips (shown by git merge-base). Multiple equal ancestors are merged into a virtual base.

  • Comparing base, ours and theirs tells Git which side actually changed a region. A one-sided change wins automatically, and differing changes to the same hunk become a conflict.

  • A two-way diff of just the tips can't tell which side is authoritative, so every difference would conflict.

  • https://git-scm.com/docs/git-merge-base
  • https://dev.to/neuraldownload/git-merge-4cch
  • https://dev.to/shrsv/git-internals-how-git-merge-really-works-2dn5
  • https://www.freecodecamp.org/news/the-definitive-guide-to-git-merge/
  • https://medium.com/@nirbhaysingh281/git-merge-base-command-0dddbcb0fe69
All Git interview questions