Skip to content

Instantly share code, notes, and snippets.

@willb
Created October 14, 2009 21:11
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 willb/210416 to your computer and use it in GitHub Desktop.
Save willb/210416 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Run git-tidy instead of "git clean" to keep from shooting yourself
# in the foot. Use "-i" to examine each file to be deleted.
function noninteractive() {
git clean -n | grep "Would remove"
echo
echo -n "Really delete the preceding files? (yes/no) "
while read input ; do
case "$input" in
yes) git clean ; exit ;;
YES) git clean ; exit ;;
no) exit;;
NO) exit;;
esac
echo 'Please enter "yes" or "no"'
echo -n "Really delete the preceding files? (yes/no) "
done
}
function interactive() {
git clean -n | grep "Would remove" | cut -c14- | tr \\n \\0 | xargs --null --interactive -L 1 rm
}
if [ "x$1" = "x-i" ] ; then
interactive
else
noninteractive
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment