Created
November 12, 2015 11:17
-
-
Save paulboardman/34ca445b95026d3450b3 to your computer and use it in GitHub Desktop.
Git: remove files from index that are listed in .gitignore
This file contains hidden or 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
# list the files in the index that are ignored via patterns in .gitignore | |
git ls-files -i --exclude-from=.gitignore | |
# remove these files - assuming filenames with no spaces or special characters | |
git rm --cached $(git ls-files -i --exclude-from=.gitignore) | |
# remove these files - assuming filenames with spaces (urgh!) | |
git ls-files -i --exclude-from=.gitignore -z | xargs -0 git rm --cached |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment