Permalink
Browse files

Add git-clean-except to clean all ignored and untracked files while k…

…eeping files listed in .gitexcept.
  • Loading branch information...
1 parent 7a963af commit 7ed2238cc68c2de0f41858a7df9b2c70e9278e47 Wayne Walter committed Feb 9, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 git-clean-except
View
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Clean all files that are ignored and not tracked, but exclude those listed in .gitexcept file.
+# Example:
+# git clean-except
+
+except=`cat .gitexcept | tr -d '\r' | tr '\n' '|' | sed "s/|$//"`
+files="git ls-files -o -i --exclude-standard"
+count=`$files | egrep -v $except | wc -l`
+if [ $count -eq 0 ]
+then
+ echo "Already clean!"
+else
+ echo "Deleting these files:"
+ $files | egrep -v $except
+ $files | egrep -v $except | xargs rm
+ echo "$count files cleaned."
+fi

0 comments on commit 7ed2238

Please sign in to comment.