docwhat's avatardocwhat's blog

git gc for a bunch of directories

last updated

Every so often, you might want to run git gc to keep your git repositories running fast. Here’s an easy way to do that.

Assuming you have your git repositories in ~/projects:

find ~/projects -name '.git' -type d -print0 | xargs -0 -Iq env GIT_DIR=q git gc

This works for git fsck as well.

Ciao!

Edit on GitHub