Skip to content

Instantly share code, notes, and snippets.

@rwarren
Created December 9, 2024 01:54
Show Gist options
  • Save rwarren/fb26ee8f471d7fb1bc5c063fad3f6652 to your computer and use it in GitHub Desktop.
Save rwarren/fb26ee8f471d7fb1bc5c063fad3f6652 to your computer and use it in GitHub Desktop.
Calculate incremental repository size changes for each Git commit.
#!/bin/sh
# This dumps the sum of file size changes (completely ignoring git repo compression)
git rev-list --all --max-parents=1 | nl -v 0 | while read index commit; do \
size=$(git ls-tree -r --long "$commit" | awk '{total+=$4} END {print total}'); \
parent=$(git rev-parse "$commit^" 2>/dev/null); \
parent_size=$(git ls-tree -r --long "$parent" | awk '{total+=$4} END {print total}'); \
delta=$((size - parent_size)); \
short_hash=$(git rev-parse --short "$commit"); \
summary=$(git log --format=%s -n 1 "$commit"); \
printf "%3s %7s %10d bytes %s\n" "$index" "$short_hash" "$delta" "$summary"; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment