Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Output all non-merged refs in a git repo, ordered by number of changed lines in the diff output
#!/bin/bash
#
# Output all non-merged refs in a git repo, ordered by number of changed lines in the diff output
#
git for-each-ref --shell --format="ref=%(refname)" --no-merged | \
while read entry
do
eval "$entry"
size=$(git diff -U0 "master...$ref" | grep -vP '^(diff|index|@@|\-\-\-|\+\+\+)' | wc -l)
echo "$size:$ref"
done |\
sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.