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
A more robust and simple option would be disabling the READ and Execution permission of the .git
directory.
Since mostly Apache (httpd) runs under a special user account, for example, it runs as user apache
on CentOS, while the .git
directory must be created under a real user account, so we can simply block the access by changing the permission. Moreover, this approach doesn't introduce any new file, nor affect the git commands.
The command can be:
chmod -R o-rx .git