Protect .git Folders on Your Webserver

If you want to deny access to files in your .git folders, add this to your .htaccess.

RedirectMatch 404 /.git

The statement denies access to the .git folder and to files like .gitignore or .gitmodules.