#!/bin/bash function branches { git for-each-ref --format="%(refname:short)" "$@"; } git fetch --all --quiet mapfile -t branches < <( branches refs/heads ) for i in "${branches[@]}"; do [ "$DEBUG" ] && printf "Checking branch <%s>\n" "$i" mapfile -t others < <( branches refs/{heads,remotes/\*}/"$i" ) [ "$DEBUG" ] && printf "Across remotes:" && printf " <%s>" "${others[@]}" && printf "\n" mapfile -t bases < <( git merge-base --octopus --all "${others[@]}" ) [ "$DEBUG" ] && printf "Merge bases:" && printf " <%s>" "${bases[@]}" && printf "\n" git log --graph --oneline --boundary "${others[@]}" --not "${bases[@]}" done