Skip to content

Instantly share code, notes, and snippets.

@ptitfred
Created April 12, 2012 15:05
Show Gist options
  • Save ptitfred/2367973 to your computer and use it in GitHub Desktop.
Save ptitfred/2367973 to your computer and use it in GitHub Desktop.
Remove new files, preserve ignored files
#!/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