如何使用composer来安装git存储库的一部分? [英] How to use composer to install part of a git repository?

查看:721
本文介绍了如何使用composer来安装git存储库的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要一个git存储库的一个子部分(而不是完整的东西)。我想这样做的原因是因为存储库是巨大的。



在我的例子中,存储库是: https:// github。 com / pubnub / pubnub-api.git ,我只想要/ php目录。



我在作曲家中定义了以下软件包:

  {
type:package,
package:{
name:pubnub,
version:dev-master,
source:{
url:https://github.com/pubnub/pubnub-api.git,
type:git,
reference :master
}
}
},



解决方案

鉴于 ,并且作曲者需要子目录检出功能来满足所需的功能,那么我建议最好的作曲家可以做的是检出



更长的答案:


是git可以做一个稀疏检出所以在理论上作曲家可以有一天支持那个功能。您可以使用自动加载字段仅加载所需的代码段(即,不加载整个lib)。


I want to require only a sub portion of a git repository (instead of the full thing). The reason i want to do this is because the repository is huge.

In my case the repository is: https://github.com/pubnub/pubnub-api.git and I only want the /php directory.

I have the following package defined in composer:

   {
            "type": "package",
            "package": {
                "name": "pubnub",
                "version": "dev-master",
                "source" : {
                    "url": "https://github.com/pubnub/pubnub-api.git",
                    "type": "git",
                    "reference":"master"
                }
            }
    },

Any tips?

解决方案

Given the answer to "Is there any way to clone a git repository's sub-directory only?" Is "No" , and sub directory checkout functionality would be required by composer to satisfy the desired functionality, then I would suggest the best composer could do was checkout the whole thing and then delete what you didnt want.

In short: Not Possible.

The longer answer: is that git can do a sparse checkout so in theory composer could someday support that feature. You can use the autoload field to only load the section of code you want (ie, not load the whole lib).

这篇关于如何使用composer来安装git存储库的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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