Created
December 31, 2017 08:44
-
-
Save lilydjwg/bae8e2e496496cdcd184834586ea35a4 to your computer and use it in GitHub Desktop.
git-ls-large: find large objects in your git repo
This file contains hidden or 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 -e | |
if [[ $# -gt 1 ]]; then | |
idx=($@) | |
else | |
idx=(.git/objects/pack/pack-*.idx) | |
fi | |
objects=$(git verify-pack -v "${idx[@]}" | grep -v -e 'non delta' -e 'chain length' -e '.git/objects' | sort -k3nr | head) | |
echo "All sizes are in kiB's. The pack column is the size of the object, compressed, inside the pack file." | |
output="size,pack,SHA,location" | |
while read -r line; do | |
# extract the size in bytes | |
size=$(($(awk -F' ' '{print $3}' <<< "${line}")/1024)) | |
# extract the compressed size in bytes | |
compressedSize=$(($(awk -F' ' '{print $4}' <<< "${line}")/1024)) | |
# extract the SHA | |
sha=$(awk -F' ' '{print $1}' <<< "${line}") | |
# find the objects location in the repository tree | |
other=$(git rev-list --all --objects | grep "$sha") | |
output="${output}\n${size},${compressedSize},${other}" | |
done <<< "${objects}" | |
echo -e "$output" | column -t -s ', ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment