#!/bin/bash
branches=`git for-each-ref --format='%(refname:short)' refs/heads/*`

for branch in $branches; do
  upstream=$(git rev-parse --abbrev-ref $branch@{upstream} 2>/dev/null)
  if [[ $? == 0 ]]; then
    echo $branch tracks $upstream
  else
    echo $branch has no upstream configured
  fi
done

