Skip to content

Instantly share code, notes, and snippets.

@nvk
Last active December 16, 2015 08:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvk/5404237 to your computer and use it in GitHub Desktop.
Save nvk/5404237 to your computer and use it in GitHub Desktop.
Compress git repos (git gc) recursively
# 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
}
@nvk
Copy link
Author

nvk commented Apr 23, 2013

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

@GUIpsp
Copy link

GUIpsp commented Apr 23, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment