Tidying up a git repo

git clone --bare --mirror [path] du -h [folder]

10 largest commits

git verify-pack -v objects/pack/[file].idx | sort -k 3 -n | tail -10

git rev-list --objects --all | grep [hash] - find the files (e.g. 5541740b808089a6738d6d830ffac0b9b31c4732 html/ukpi/6UK-P&I_Publication_home.jpg)

Need git-filter-repo installed

git filter-repo --path [path] --invert-paths

git gc --aggressive --prune=now

delete, git add origin git push etc

git fetch origin git reset --hard [branch]

This website is currently having a full content audit - apologies if some of the code or content looks a bit funky!

View this post on Gitlab

You might also enjoy…

Mike Street

Written by Mike Street

Mike is a front-end developer from Brighton, UK. He spends his time writing, cycling and coding. You can find Mike on Twitter.