Skip to content

Instantly share code, notes, and snippets.

@MatthiasLohr
Created November 11, 2020 06:51
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 MatthiasLohr/692d2dd57612a08b07a779c9883e521b to your computer and use it in GitHub Desktop.
Save MatthiasLohr/692d2dd57612a08b07a779c9883e521b to your computer and use it in GitHub Desktop.
#!/bin/sh
# (c) by Matthias Lohr <matthias@lohr.me> 2014
# Read LICENSE file for license information.
CURDIR="$(pwd)"
if [ "$1" = "" ] ; then
REPOSDIR="$CURDIR"
else
REPOSDIR="$1"
fi
FILES_BEFORE=$(find "$REPOSDIR" -type f | wc -l )
SPACE_BEFORE=$(du -sh "$REPOSDIR")
echo Current: $SPACE_BEFORE in $FILES_BEFORE files
for ITEM in $(find "$REPOSDIR" -type d -name "*.git") ; do
echo "Cleaning up $ITEM..."
cd "$ITEM"
git gc --aggressive
cd "$CURDIR"
done
FILES_AFTER=$(find "$REPOSDIR" -type f | wc -l )
SPACE_AFTER=$(du -sh "$REPOSDIR")
echo Before: $SPACE_BEFORE in $FILES_BEFORE files
echo Now: $SPACE_AFTER in $FILES_AFTER files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment