Skip to content

Instantly share code, notes, and snippets.

@hymerman
Last active December 16, 2015 05:48
Show Gist options
  • Save hymerman/5386722 to your computer and use it in GitHub Desktop.
Save hymerman/5386722 to your computer and use it in GitHub Desktop.
Git remove ignored files already added to the repo. This works on windows with msysgit (tested with version 1.8.0.msysgit.0). Leaves deleted files in place because of --cached. The key part is the `-z` which makes ls-files use a null character as the delimiter, which works with xargs' -0 option to separate lines without blowing up on paths with …
#!/bin/sh
git ls-files -i -z --exclude-standard | xargs -0 -r git rm --cached
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment