Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…eeping files listed in .gitexcept.
  • Loading branch information...
commit 7ed2238cc68c2de0f41858a7df9b2c70e9278e47 1 parent 7a963af
Wayne Walter authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 git-clean-except
View
17 git-clean-except
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.