Skip to content

Instantly share code, notes, and snippets.

@pandres95
Created January 2, 2019 01:04
Show Gist options
  • Save pandres95/1c17c800c9bbabeae2e1aab3fa66e871 to your computer and use it in GitHub Desktop.
Save pandres95/1c17c800c9bbabeae2e1aab3fa66e871 to your computer and use it in GitHub Desktop.
Recursively removes ignored files inside git repos across a folder.
#!/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