Add the following to user preferences (Preferences / Settings – User):
"folder_exclude_patterns": [".git", "node_modules", "bower_components"]
Make sure to restart sublime for the changes to take effect.
The problem with this setting is that it also removes these folders from the sidebar.
If you still want to see the files in the sidebar but still exclude them from search and Ctrl + P you can instead use
"binary_file_patterns": [".git/", "node_modules/", "bower_components/"]
Note that a forward slash is required at the end for directories.
Remember to restart Sublime again.