Compressing All Git Repositories On Your Machine
2019 June 27

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.

find $DIRS -name '.git' -type d | while read line
    pushd $line/..
    git gc --aggressive

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.

Remember you can also subscribe using RSS at the top of the page!

Share this on → Mastodon Twitter LinkedIn Reddit

A selected list of related posts that you might enjoy:

Written by Henry J Schmale on 2019 June 27
Hit Counter