git ignore all files and directories recursively except the .gitignore file


I found myself looking this up a few times and each time coming up with a slightly different variation, so here’s to saving the one I’m looking for. This will ignore all directories and files in the current directory except this .gitignore file. If you toss this in your bower_components directory and have third party code in there with their own .gitignore files, you won’t be prompted to version those :).

Save this in a .gitignore file

*
!/.gitignore

Leave a comment

Your email address will not be published. Required fields are marked *