I have a website that I use github (closed source) to track changes and update site. The only problem is, it appears the .git directory is accessible via the web. How can I stop this and still be able to use git?
Should I use .htaccess? Should I change permissions of .git?
Put this in an .htaccess
file at the root of your web server:
RedirectMatch 404 /\.git
This solution is robust and secure: it
.git
directories in your site, even if there are more than one,.gitignore
and .gitmodules
.git
directories, and