Skip to content

Instantly share code, notes, and snippets.

@shaunakv1
Last active August 29, 2019 03:53
Show Gist options
  • Save shaunakv1/6ba0d8fe725ee19eadd39fc49451544a to your computer and use it in GitHub Desktop.
Save shaunakv1/6ba0d8fe725ee19eadd39fc49451544a to your computer and use it in GitHub Desktop.
Cleaning up Large Git Repos

Find out sizes of all files in all the history

git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest \
| tee file-size-list

Run Cleanup using bfg

java -jar bfg-1.13.0.jar --delete-files "{*.mp4} " svn-to-git/repos/digitalcoast_v4_site/.git

java -jar bfg-1.13.0.jar --delete-folders build ./svn-to-git/repos/digitalcoast_site/.git

Reflog and Push

git reflog expire --expire=now --all && git gc --prune=now --aggressive

Check the repo size

git count-objects -vH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment