Skip to content

Instantly share code, notes, and snippets.

@mAu888
Created November 1, 2012 12:50
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 mAu888/3993450 to your computer and use it in GitHub Desktop.
Save mAu888/3993450 to your computer and use it in GitHub Desktop.
git safe clean
#!/bin/bash
# Place this script under /usr/bin or /usr/local/bin
# and make it executable with sudo chmod +x /path/to/the/script/git-sclean
#
# Run git sclean from terminal and be happy!
# Dry-run git clean
git clean -n
CLEARFILES=$(git clean -n | wc -l | sed 's/[^0-9]*\([0-9]*\)[^0-9]*/\1/')
echo -n "Clean $CLEARFILES files (y/n)? "
read yesOrNo
if [ "$yesOrNo" = "y" ]; then
git clean -f
else
echo "Aborting cleanup..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment