So you are developing a new shiny windows app and dare to use Git to version control it. In console. And you forgot to put a proper .gitignore file for Visual studio project before committing everything to the repository. Congratulations, you are not the only one who did that. :)

In order to clean everything up in the repo go ahead and delete all bin and obj folders from all of your projects. Also be sure to put a proper gitignore file in the root of your repo.

Now, how do you make Git know that you’ve just deleted of all those *.dll and *.pdb files? If you run git status, you’ll see that they are still indexed.

So to fix that on Linix you could do:

$ git rm $(git ls-files --deleted)    # Linux

I never would have thought that there is an exact translation of this to Windows-speak. You need to have Git binaries in your PATH, and everything should work right away. Here is the one-liner:

$ for /f "delims=" %a in ('git ls-files --deleted') do (git rm "%a")   # Windows