Quick Git command-line tip: cleaning up your repository from extra files (say, when working with ASP.NET 5)

Posted: (EET/GMT+2)

 

I've noticed that especially when working with the new ASP.NET 5 web applications, your project folder(s) sometimes get polluted with extra files you don't need. When working with Git version control this usually leads to more files living inside your repository than would actually be needed.

Luckily, the command-line Git client is powerful, and with a single command, you can clean up your repository from files that are not part of source control. To do this, you can execute the following command:

git clean -xdf

As noted in the Git's clean command documentation, the parameters "x", "d" and "f" start for "don't mind the ignore rules", "delete directories" and "force", respectively. Note that casing is important here: "x" and "X" are different here.