Skip to content

Instantly share code, notes, and snippets.

@andyscott
Created May 26, 2011 14:31
Show Gist options
  • Save andyscott/993267 to your computer and use it in GitHub Desktop.
Save andyscott/993267 to your computer and use it in GitHub Desktop.
WIP script for determining which repos are ahead/behind origin
#!/bin/sh
dg="\e[0;32m"
r="\e[1;31m"
b="\e[1;34m"
m="\e[1;35m"
cyan="\e[1;36m"
rs="\e[0m"
pdir=${PWD##*/}
echo -e "$cyan$pdir$rs"
echo " branch status delta"
for ref in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
uref=${ref}'@{upstream}'
! git rev-parse --verify --quiet "$uref" >/dev/null 2>&1 && {
printf "$b%10s$dg local\n" $ref
continue
}
ahead=`git rev-list "$uref..$ref" | wc -l`
test $ahead -gt 0 && {
printf "$b%10s$dg ahead $rs+$ahead\n" $ref
continue
}
behind=`git rev-list "$ref..$uref" | wc -l`
test $behind -gt 0 && {
printf "$b%10s$dg behind $r-$behind\n" $ref
}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment