So I recently felt the need to compress all the git repositories on my machine. This was mainly because I wanted to reduce the number of files I had to wait to backup. So here’s the commands I used to make that happen.
So this just walks over all the directories that contain the magic git
data folder, and runs git gc
on it. The gc
command in git asks for
garbage collection and for objects to be packed up into it’s actual
archive bundle. The pushd
and popd
commands allow us to end up in
the original directory we started at.
In my case I only cared about git repos in my home directory, but you could select any place to run this command.