I keep running into a scenario where someone on our team pushes an initial commit without first adding a .gitignore to their project. This results in a bunch of files ending up in the repo that we don't want tracked.
git ls-files -i --exclude-from=.gitignore
gives me a list of files that are ignored by .gitignore
and
git rm --cached <file>
lets me remove files one at a time from the repo, but keeps them in my working directory (which I want)
Is there a way I can pipe the file list from ls-files
to rm --cached
(or some other method altogether that will allow me to remove the tracked, ignored files from my repo)?
One of our team members wrote a shell script that uses regex to do it, but I'm looking for a command-line only solution (if one exists).