public
Last active

Compress git repos (git gc) recursively

  • Download Gist
gspace.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12
# Compress git repos (git gc) recursively
# Use as at will, by @nvk
 
gspace(){
for gitdir in `find ./ -name .git`;
do
workdir=${gitdir%/*};
hrline 44; # see http://gist.github.com/nvk/5340820
echo $workdir;
git --git-dir=$gitdir --work-tree=$workdir gc --aggressive;
done
}

Compress git repos (git gc) recursively

Like most i have a src folder where most my repos are, I notice a big HDD space decrease working on projects with bigger groups (many commits a day). I bumped into git gc --agressive, which is great, but i wanted to run trough all repos since it's non destructive.

PS: I'm not a dev, I'm sure there is better ways of writing this.

Preview

Preview

As a one liner:
find -name .git -execdir git gc --aggressive ";"
Even tho this one is fancier

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.