Jeff King [off-list ref] writes:
Try:
test -z "$(git rev-list -1 origin..HEAD)" &&
echo nothing that needs pushing
You can also use --count to get the exact number, but if you just care
whether there is something or nothing, using "-1" lets git stop the
graph traversal immediately.
Doesn't some variant of "branch -v" show the ahead/behind information for
all branches?