For complicated branches, there might be more than one boundary. It's suggested to add a "tail -n 1" to get the last boundary.
(This command was found incorrect in some case, multiple boundary found, but the last boundary wasn't the desired one, but the second last.)
git rev-list --boundary HEAD...master | grep ^- | cut -c2- | tail -n 1
Determining if a Git repository contains a particular commit - Stack Overflow
if [ "$(git rev-parse $commitA)" == "$(git merge-base $commitA $commitB)" ]; then ...; else ...; fi"git merge-base" will also get the result of finding the branch point, for merge-base is the branch point of the two branches.
git merge-base $commitA $commitB
git rev-list --boundary branch-a...master | grep ^- | cut -c2-
or add it to aliases in ~/.gitconfig :
diverges = !sh -c 'git rev-list --boundary $1...$2 | grep ^- | cut -c2-'
so I can call it as:
git diverges branch-a master