docwhat's avatardocwhat's blog

git maintenance run for a bunch of directories

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

Using xargs:

find ~/ -name '.git' -type d -print0 |
    xargs -0 -I'{}' git --git-dir='{}' maintenance run --auto

Using GNU parallel:

find ~/ -name '.git' -type d -print0 |
    parallel -0 --halt soon,fail=1 "git --git-dir={} maintenance run --auto"
Edit on GitHub