Created
December 15, 2015 11:55
-
-
Save erykpiast/0ec254b63803ef5697d3 to your computer and use it in GitHub Desktop.
Clean untracked files in git more safely
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
function git_clean_untracked_safely { | |
TO_REMOVE=`git clean -f -d -n`; | |
TO_REMOVE_LINES=`git clean -f -d -n | wc -l`; | |
if [ "$TO_REMOVE_LINES" -ne "0" ]; then | |
echo "Cleaning"; | |
printf "\n$TO_REMOVE\n\n"; | |
echo "Proceed?"; | |
select result in Yes No; do | |
if [[ "$result" == "Yes" ]]; then | |
echo "Cleaning in progress..." | |
git clean -f -d; | |
echo "Cleaning finished!" | |
fi | |
break; | |
done; | |
else | |
echo "Everything is clean"; | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment