Last active
October 2, 2023 13:38
-
-
Save magnetikonline/4064851 to your computer and use it in GitHub Desktop.
Recursively garbage collect (compress) all child Git repositories from a given base directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [[ ! -d $1 ]]; then | |
echo "Usage: $(basename "$0") DIR" | |
exit 1 | |
fi | |
IFS=$'\n' | |
for gitRepoDir in $(find "$(readlink -f "$1")" -type d -name ".git"); do | |
gitRepoDir=${gitRepoDir%/.git} | |
echo | |
echo | |
echo "$gitRepoDir" | |
git --git-dir "$gitRepoDir/.git" gc --aggressive --prune=now | |
echo | |
done | |
unset IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment