Find large files inside your git repository.

Deepak
TarkaLabs TIL
Published in
1 min readFeb 2, 2018

Sometimes I have found large static files commit-ed into the git repository and not been removed out of the git DB when deleted. This bloats the repository.

git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| awk '/^blob/ {print substr($0,6)}' \
| sort --numeric-sort --key=2 \
| cut --complement --characters=13-40 \
| numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest

This comes in handy to find such big files.

PS: For Mac you can brew install coreutils, replace cut with gcut and numfmt with gnumfmt.

--

--