.gitattributes中export-ignore属性
文章目录
下面是某个项目的 .gitattributes 文件内容
* text=auto
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpunit.php export-ignore
phpunit.xml.dist export-ignore
phpunit.xml export-ignore
.php_cs
从中可以看到 export-ignore属性,它是做什么用的呢?
适用场景如下:
当你的项目是作为一个扩展发布在 packagist.orgs 上的时候,或许使用者需要的只是你的src文件夹和composer.json文件,而不需要其他的一些文件,它的作用就是会忽略这些文件。
举个例子:
当使用composer安装你的软件包(扩展包)的时候, --prefer-dist 会从github或cvs下载一个zip包,并将其解压缩。
使用.gitattributes文件,可以通过添加export-ignore属性来忽略不需要下载的文件。
比如以下配置:
# .gitattributes
.travis.yml export-ignore
在使用composer安装扩展的时候,.travis.yml 文件是不会下载下来的。
注意⚠️:
Composer缺少对"dist"的Gitlab支持,因此目前这对Gitlab不起作用。但是,它适用于Github和Bitbucket
参考:
Use gitattributes to keep your tests out of other people’s production
I don’t need your tests in my production
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论