Skip to content

Instantly share code, notes, and snippets.

@jahanson
Last active December 23, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahanson/6563942 to your computer and use it in GitHub Desktop.
Save jahanson/6563942 to your computer and use it in GitHub Desktop.
Linux git command that removes files in your repo that apply to the .gitignore but doesn't delete them. Ex. You added some rules after a while and need them to be applied immediately.
#!/bin/bash
(GIT_INDEX_FILE=some-non-existent-file \
git ls-files --exclude-standard --others --directory --ignored -z) |
xargs -0 git rm --cached -r --ignore-unmatch --
@jahanson
Copy link
Author

From stack overflow post http://stackoverflow.com/a/3262033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment