Created
April 12, 2012 15:05
-
-
Save ptitfred/2367973 to your computer and use it in GitHub Desktop.
Remove new files, preserve ignored files
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 | |
# This can be used this way : git rm-others <rm-options> | |
# It will remove files with the status "?" and preserve files ignored. | |
# It won't remove empty directories unlike git clean -fdx | |
# This file should be renamed to git-rm-others and appended to the PATH | |
# The file is named git-rm-others.sh to enable gist syntax colorization | |
RM_OPTIONS=$* | |
files=$(git ls-files -o --exclude-standard) | |
if [[ $(echo $files | wc -w ) -gt 0 ]]; then | |
rm $RM_OPTIONS $files | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment