Skip to content

Commit f702f9a

Browse files
jehiahbill-auger
authored andcommitted
initial commit - print commits ahead<->behind counts
0 parents  commit f702f9a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

git-branch-status

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# by http://github.com/jehiah
3+
# this prints out some branch status (similar to the '... ahead' info you get from git status)
4+
5+
# example:
6+
# $ git branch-status
7+
# dns_check (ahead 1) | (behind 112) origin/master
8+
# master (ahead 2) | (behind 0) origin/master
9+
10+
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \
11+
while read local remote
12+
do
13+
[ -z "$remote" ] && continue
14+
git rev-list --left-right ${local}...${remote} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue
15+
LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta)
16+
RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)
17+
echo "$local (ahead $LEFT_AHEAD) | (behind $RIGHT_AHEAD) $remote"
18+
done

0 commit comments

Comments
 (0)