Skip to content

Instantly share code, notes, and snippets.

@ku
Created July 1, 2012 08:00
Show Gist options
  • Select an option

  • Save ku/3027463 to your computer and use it in GitHub Desktop.

Select an option

Save ku/3027463 to your computer and use it in GitHub Desktop.
remove git untracked files
#!/bin/sh
dir=`pwd`
while true ; do
if test -d "$dir/.git"
then
break
else
dir=`dirname $dir`
if test "$dir" = "/"
then
exit 1
fi
fi
done
files=`git status --porcelain | egrep '^\?\?' | cut -f 2 -d ' '`
for file in $files
do
rm -f "$dir/$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment