Created
January 2, 2019 01:04
-
-
Save pandres95/1c17c800c9bbabeae2e1aab3fa66e871 to your computer and use it in GitHub Desktop.
Recursively removes ignored files inside git repos across a folder.
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 | |
cwd=$(pwd) | |
IFS=$'\n' | |
for dir in $(find . -type d); do | |
cd $cwd | |
dir=${dir// /\\ } | |
echo $dir | |
if ls "$dir" &> /dev/null; then | |
cd "$dir" | |
if ls .git &> /dev/null; then | |
echo ".git found at $dir. Cleaning" | |
git clean -fdX | |
fi | |
else | |
echo "Couldn't find $dir" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment