git merge-base <branchname1> <branchname2>

Finds common ancestor(s) between two branches

This command performs a search for common ancestor commit(s) between the two specified branches.

It's often used to find the point at which two branches diverged. The command will output the commit hash(es) of the common ancestor commit(s).

If multiple common ancestors are found, this command displays one of them. While the command often displays the immediate shared ancestor, this is not guaranteed. Other branches can be targeted by specifying their names instead of <branchname1> and <branchname2>.

It's also possible to find common ancestors of more than two branches by specifying additional branch names after <branchname2>.