Skip to content

Instantly share code, notes, and snippets.

@wolph
Created July 23, 2012 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolph/3163680 to your computer and use it in GitHub Desktop.
Save wolph/3163680 to your computer and use it in GitHub Desktop.
Global git garbage collect
[alias]
global-gc = !git-global-gc.sh
#!/bin/sh
if [ "$#" -eq 1 ]; then
# If we have arguments, get the dirname for the given path
name=$(dirname "$@")
echo "Garbage collecting $name"
cd "$name"
git gc --aggressive || true
echo "Done collecting garbage in $name\n"
else
# Use the locate database to find all .git directories
locate .git | grep '/\.git$' | xargs -d '\n' -L1 $0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment