Git忽略子模块中的文件/目录 [英] Git ignore file/dir in submodule

查看:347
本文介绍了Git忽略子模块中的文件/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git可以配置为忽略子模块内的某些文件/文件夹/路径吗?

Can git be configured to ignore certain files/folders/paths that are within a submodule?

我的项目中的一个子模块(PHP)附带测试包括shell脚本和其他潜在危险的内容,我不想在我的Web服务器上拥有这些内容。

One of the submodules in my project (PHP) ships with a test directory including shell scripts and other potentially dangerous content, which I don't want to have on my Webserver.

在我的主repo中是否有配置魔术 / strong>忽略 / modules / A / test / * ,这样克隆/获取/更新子模块后这些文件将不可访问?

Is there any configuration magic within my main repo to ignore /modules/A/test/*, so that these files will not be accessible after cloning/fetching/updating submodules?

(或者,让git在正确的位置添加一个静态的.htaccess文件也会很好)

(Alternatively, having git add a static .htaccess file in the right location would be great, too)

推荐答案

不,即使 .gitignore 会在子模块上生效(它不会), .gitignore 对已经跟踪的文件没有任何影响。它只是告诉Git忽略它尚未跟踪的文件。

No, even if .gitignore would take effect on submodules (it does not), .gitignore does not have any effect on already tracked files. It just tells Git to ignore files it does not yet track at all.

这篇关于Git忽略子模块中的文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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