Skip to content

Instantly share code, notes, and snippets.

@Lacrymology
Last active August 22, 2018 17:27
Show Gist options
  • Save Lacrymology/dcbbbc41d1d56690cf35e9700976e963 to your computer and use it in GitHub Desktop.
Save Lacrymology/dcbbbc41d1d56690cf35e9700976e963 to your computer and use it in GitHub Desktop.
Git alias to list files by size
git config --global alias.list-sizes-2 '!f() { git rev-list --objects --all | git cat-file --batch-check="%(objecttype) %(objectname) %(objectsize) %(rest)" | sed -n "s/^blob //p" | sort --numeric-sort --key=2 | cut -c 1-12,41- | numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest ; } ; f'
## Here's the command divided, to make it more clear
# git rev-list --objects --all
# | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'
# | sed -n 's/^blob //p'
# | sort --numeric-sort --key=2
# | cut -c 1-12,41-
# | numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment