Last active
August 29, 2015 14:04
-
-
Save gergelypolonkai/8af6a3e86b57dd4c250e to your computer and use it in GitHub Desktop.
List git branches and their remote tracking branch, if any
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
COLUMN=`which column 2> /dev/null` | |
if test -z $COLUMN | |
then | |
echo "\`column' is not found in PATH. Cannot continue." | |
exit 1 | |
fi | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
for branch in $(git for-each-ref --shell --format='%(refname)' refs/heads | sed -e s/^\'refs\\/heads\\/// -e s/\'$//) | |
do | |
remote=`git config branch.$branch.remote` | |
merge=`git config branch.$branch.merge | sed -e 's/^refs\/heads\///'` | |
[ x"$current_branch" == x"$branch" ] && echo -n '*' | |
echo -n "$branch" | |
if ! test -z $merge | |
then | |
echo -en "\t" | |
echo -n $remote | |
echo -n / | |
echo -n $merge | |
fi | |
echo | |
done | $COLUMN -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment