Make .git directory web inaccessible

后端 未结 9 1715
耶瑟儿~
耶瑟儿~ 2020-11-30 17:22

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

9条回答
  •  抹茶落季
    2020-11-30 18:05

    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
    

提交回复
热议问题