Skip to content

Instantly share code, notes, and snippets.

@andrewfowlie
Created May 27, 2020 01:12
Show Gist options
  • Save andrewfowlie/b5f455f0fc2f2fb4cd919c47424f04b4 to your computer and use it in GitHub Desktop.
Save andrewfowlie/b5f455f0fc2f2fb4cd919c47424f04b4 to your computer and use it in GitHub Desktop.
function git_branch_search_stale {
echo "ahead | behind | branch name"
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/remotes | \
while read remote
do
git rev-list --left-right origin/master...${remote} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue
BEHIND=$(grep -c '^<' /tmp/git_upstream_status_delta)
AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)
echo "$AHEAD $BEHIND $remote"
done | \
sort -n
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment