Skip to content

Instantly share code, notes, and snippets.

@anthonycarminati
Last active February 1, 2016 16:38
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 anthonycarminati/d250964178fc372a826e to your computer and use it in GitHub Desktop.
Save anthonycarminati/d250964178fc372a826e to your computer and use it in GitHub Desktop.
This code applies the logic defined in a .gitignore file, even after files have been committed to a repository. Note: this does not delete files locally, it only removes them from version control.
git rm --cached `git ls-files -i -X .gitignore`
@anthonycarminati
Copy link
Author

Usage:

  • update .gitignore file with the file definitions you'd like to remove from your git repository (or prevent from being added)
  • navigate to your git repo from the command line and run the apply_gitignore script from the repo's root folder

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