Skip to content

Instantly share code, notes, and snippets.

@bjorg
Created April 9, 2013 21:59
Show Gist options
  • Select an option

  • Save bjorg/5349797 to your computer and use it in GitHub Desktop.

Select an option

Save bjorg/5349797 to your computer and use it in GitHub Desktop.
Script for showing all Git branches and what remote branch they are mapped to (if any).
#!/bin/sh
git for-each-ref --format='%(refname:short)' refs/heads/* | while read b
do if r=$(git config --get branch.$b.remote)
then
m=$(git config --get branch.$b.merge)
echo "$b -> $r/${m##*/}"
else
echo "$b -> MISSING REMOTE"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment