Created
September 13, 2023 15:33
-
-
Save beenotung/5f8610007d10ffd0515804249a92a89b to your computer and use it in GitHub Desktop.
find large files from git blob store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o pipefail | |
case "$1" in | |
-s|--sum) | |
git rev-list --objects --all \ | |
| git cat-file --batch-check='%(objecttype) %(objectsize) %(rest)' \ | |
| sed -n 's/^blob //p' \ | |
| awk '{x+=$1}END{print x}' \ | |
| $(command -v gnumfmt || echo numfmt) --field=1 --to=iec-i --suffix=B --round=nearest | |
exit | |
;; | |
-r) | |
order="-rn" | |
;; | |
*) | |
order="-n" | |
;; | |
esac | |
git rev-list --objects --all \ | |
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \ | |
| sed -n 's/^blob //p' \ | |
| sort "$order" --key=2 \ | |
| cut -c 1-12,41- \ | |
| $(command -v gnumfmt || echo 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