Spring clean all your git repos03 Mar 2016
Often we have a lot of git working copies at the machine. They can be old and with a lot unneeded git objects. They could be mass-cleaned to save inodes, optimize speed and lighten backups.
To ease cleaning let’s write a simple script with
gc --aggressive is misleading.
Let’s count how much objects are in all our git repositories:
(find . -name .git -type d -not -path '*exclude*' | xargs -L1 find ) | wc -l
Then use the script to mass-clean all repositories:
find . -name .git -not -path '*exclude*' | xargs -L1 -t gitcleanup.sh
And finally count again with the first one-liner.
For me this simple spring clean reduces git objects from 38631 to 7050.