Skip to content

Instantly share code, notes, and snippets.

@mattslack
Created October 17, 2013 13:53
Show Gist options
  • Save mattslack/7025284 to your computer and use it in GitHub Desktop.
Save mattslack/7025284 to your computer and use it in GitHub Desktop.
Clean up a directory full of git repos. Maybe get back some hard disk space.
#!/bin/zsh
PROJECTS_DIR="${HOME}/Projects"
cd $PROJECTS_DIR
for client in `find ${PROJECTS_DIR} -type d -name ".git"`; do
cd ${client}
cd ..
echo "Checking: `pwd`"
git gc
git remote prune origin
if [ -d log ]; then
echo "Removing logs...\c"
rm -f ./log/*.log
echo 'done.'
fi
echo ""
done
echo "Removing extra logs...\c"
find ${PROJECTS_DIR} -type f -iname "*development.log" -exec rm {} \;
find ${PROJECTS_DIR} -type f -iname "*test.log" -exec rm {} \;
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment