Edit:
After fooling in the comments a bit, we arrived at this oneliner:
git branch --format='%(refname:short)' | xargs -I{} git log --pretty=format:"%H" origin/{}...{}
It iterates over your local branch names (assuming there exists a remote version with the same name for each of them) and prints the hashes of the commits that are present in either one of the remote or local branches, but not in both.
Original answer:
First run a git fetch
to update your remote tracking branches, then try this:
git log --pretty=format:"%H" --all origin/master...master
This will show what commits are not in origin/master and master at the same time.
That triple-dot syntax is all over git commands (there's also the double-dot one); they're not exactly consistent though and I recommend this answer if you want to dig deeper.
The --all
shows the other branches as well.
You can tune it more to your liking by messing around with the dots, order, the --all
flag, and even the ^
operator.
Bonus:
You could devise a strategy to still use the iterative solution without a strict one to one mapping of local branches to remote branches with a simple text file and then just cat piping it into xargs.