-
-
Save lth2h/4177524 to your computer and use it in GitHub Desktop.
show git ahead/behind info for branches
This file contains 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/bash | |
# forked from http://github.com/jehiah | |
# this prints out some branch status (similar to the '... ahead' info you get from git status) | |
# example: | |
# $ git branch-status | |
# dns_check (ahead 1) | (behind 112) origin/master | |
# master (ahead 2) | (behind 0) origin/master | |
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \ | |
while read local remote | |
do | |
[ -z "$remote" ] && continue | |
DELTAS=$(git rev-list --left-right ${local}...${remote}) | |
LEFT_AHEAD=$(echo "$DELTAS" | grep -c '^<') | |
RIGHT_AHEAD=$(echo "$DELTAS" | grep -c '^>') | |
echo "$local (ahead $LEFT_AHEAD) | (behind $RIGHT_AHEAD) $remote" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment