git merge-base main feature

Category: Git - Advanced

git merge-base main feature

Find the common ancestor of two branches

Prints the merge base, the most recent commit shared by both branches. It is the reference point for diffs and rebases between them. Scripts use it to compute what each branch added.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.