使 .git 目录无法访问网络 [英] Make .git directory web inaccessible

查看:31
本文介绍了使 .git 目录无法访问网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我使用 github(封闭源代码)来跟踪更改和更新站点.唯一的问题是,似乎可以通过网络访问 .git 目录.我怎样才能阻止这种情况并仍然能够使用 git?

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?

我应该使用 .htaccess 吗?我应该更改 .git 的权限吗?

Should I use .htaccess? Should I change permissions of .git?

推荐答案

.git 文件夹中创建一个 .htaccess 文件,并将以下内容放入该文件中:

Create a .htaccess file in the .git folder and put the following in this file:

Order allow,deny
Deny from all

但请注意,如果您重新克隆存储库,它将会丢失

But note, that it would be lost if you ever re-cloned the repository

这篇关于使 .git 目录无法访问网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆