1
0
mirror of https://github.com/captn3m0/Scripts.git synced 2024-09-27 22:22:53 +00:00
scripts/gitlistobjectbysize.sh
2019-08-06 17:57:25 +05:30

16 lines
391 B
Bash
Executable File

#!/bin/bash -e
# work over each commit and append all files in tree to $tempFile
tempFile=$(mktemp)
IFS=$'\n'
for commitSHA1 in $(git rev-list --all); do
git ls-tree -r --long "$commitSHA1" >>"$tempFile"
done
# sort files by SHA1, de-dupe list and finally re-sort by filesize
sort --key 3 "$tempFile" | \
uniq | \
sort --key 4 --numeric-sort --reverse
# remove temp file
rm "$tempFile"