Find the largest objects in git history
A repo feels heavy and du on the working tree shows nothing. The weight is in history — a committed binary, a stray dump, a vendored archive. This lists the 20 biggest blobs across all commits, including deleted ones.
#!/usr/bin/env bash
# git-fat — list the 20 largest objects in git history, human-readable.
set -euo pipefail
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
awk '$1 == "blob" { print $3, $4 }' |
sort -rn |
head -20 |
numfmt --to=iec --field=1 |
column -t
Output is size path, biggest first:
14M assets/demo.mp4
3.2M data/export.json
...
A path here is just where the blob was last seen — the bytes live in history regardless. To actually shrink the repo, rewrite it out with git-filter-repo. numfmt and column are GNU coreutils; on macOS, brew install coreutils or run it inside a Nix shell.