Skip to content

Instantly share code, notes, and snippets.

@deeGraYve
Forked from atnan/git-clean-cached.sh
Created August 16, 2012 21:32
Show Gist options
  • Save deeGraYve/3373813 to your computer and use it in GitHub Desktop.
Save deeGraYve/3373813 to your computer and use it in GitHub Desktop.
#!/bin/bash
cat .gitignore | egrep -v "^#|^$" | while read line; do
if [ -n "$line" ]; then
OLD_IFS=$IFS; IFS=""
for ignored_file in $( git ls-files "$line" ); do
git rm --cached "$ignored_file"
done
IFS=$OLD_IFS
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment