_dump/ggc.sh

32 lines
542 B
Bash
Executable File

#!/usr/bin/env zsh
# git cleanup
if [ ! -z "$1" ]; then
GIT_DIRS_PATH="$1" # i.e. '/Forks'
FORKS=( `/bin/ls -A1 "$GIT_DIRS_PATH"` )
for FORK in "${FORKS[@]}"; do
if [ -d "$GIT_DIRS_PATH/$FORK" ]; then
cd "$GIT_DIRS_PATH/$FORK"
if [ -e "`pwd`/.git" ]; then
echo "
> '$GIT_DIRS_PATH/$FORK'"
git gc --aggressive
git repack -Ad
git prune
fi
cd "$GIT_DIRS_PATH"
fi
done
else
# script called w/o additional argumants
cd `realpath "$0" | xargs dirname`
git gc --aggressive
git repack -Ad
git prune
fi