Exclude all .git or .svn folders from Spotlight index
Solution 1:
It is possible to exclude a folder using the command-line.
From there try this:
Open a Terminal window
-
Type
sudo defaults write /.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add 'path/to/exclude'
So I guess you can try this using xargs' magic:
sudo locate .git | xargs -I {} defaults write /.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add {}
You can check it worked using this:
sudo defaults read /.Spotlight-V100/VolumeConfiguration.plist Exclusions
You can remove all entries (there is no -array-remove option) using this:
sudo defaults write /.Spotlight-V100/VolumeConfiguration.plist Exclusions -array
Be careful with these commands, I don't know if there are side effects.
I could not really check this worked for my .git folders since none of them were displayed by spotlight search before nor after running these commands.