-
-
Save Mark-Booth/5058384 to your computer and use it in GitHub Desktop.
Version of git-branch-status which only shows the current branch and only generates output if a branch is ahead or behind.Added options to:* Show all branches (revert to the old behaviour)* Show output even if the branch isn't ahead or behind (revert to the old behaviour)* Show branch(es) with respect to origin/master (inspired by git-branches-v…
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/bash | |
# forked from by 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 |
@vbjay - I've added a -u option (amongst other changes).
Thanks Mark, you saved me about a day's work with that! ^_~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be great to have another parameter that allows a different remote to be used to compare. Example:
git branch-status -av upstream