Skip to content

Instantly share code, notes, and snippets.

@Aeramor
Created July 29, 2013 19:31
Show Gist options
  • Save Aeramor/6107060 to your computer and use it in GitHub Desktop.
Save Aeramor/6107060 to your computer and use it in GitHub Desktop.
Remove any files from the repo that are in the gitignore, even after the fact. Just copy paste the whole thing into terminal/commandline (in the correct directory) and it will un-track the files (but leave them intact locally).Then use git status to verify nothing important was removed.
(GIT_INDEX_FILE=some-non-existent-file \
git ls-files --exclude-standard --others --directory --ignored -z) |
xargs -0 git rm --cached -r --ignore-unmatch --
@Aeramor
Copy link
Author

Aeramor commented Mar 17, 2015

Note: You have to navigate to the folder where the file you want ignored is located before running this command!

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