-
-
Save monkeycycle/814f813f7946464fc78b8b095917a35f to your computer and use it in GitHub Desktop.
Remove previously commit files in update .gitignore - ala http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After editing .gitignore to match the ignored files, you can do git ls-files -ci --exclude-standard to see the files that are included in the exclude lists; you can then do git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached to remove them from the repository (without deleting them from disk). | |
Edit: You can also add this as an alias in your .gitconfig file so you can run it anytime you like. Just add the following line under the [alias] section: | |
apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached | |
(The -r flag in xargs prevents git rm from running on an empty result and printing out its usage message.) | |
Now you can just type git apply-gitignore in your repo, and it'll do the work for you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment