Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Last active January 29, 2020 00:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinsmidsrod/c4e541f728feeaa8a31795eeef9241e3 to your computer and use it in GitHub Desktop.
Save robinsmidsrod/c4e541f728feeaa8a31795eeef9241e3 to your computer and use it in GitHub Desktop.
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