Skip to content

Instantly share code, notes, and snippets.

@leontiy
Created July 12, 2009 17:43
Show Gist options
  • Save leontiy/145700 to your computer and use it in GitHub Desktop.
Save leontiy/145700 to your computer and use it in GitHub Desktop.
#!/bin/bash
USAGE="usage: git-gc-all [repositories_directory]"
if [[ -z $1 ]]; then
wd=`pwd`
elif [[ $1 == "--help" ]]; then
echo "runs git-gc in each subdirectory of current directory."
echo $USAGE
exit
else
wd=$1
fi
echo Optimizing repositories in $wd:
pushd $wd
for repo in `ls`; do
echo "****************************************"
echo " $repo"
echo "****************************************"
pushd $repo
git-gc > /dev/null
popd
done
popd
echo
echo "Optimization complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment