Here is what worked for me. It is kind of a combination of multiple solutions here:
git log <main-branch-name>..<branch-name> --pretty=oneline | wc -l