Pat*_*Yan 9 php git github composer-php
我有类似的东西
"repositories": [
{
"type": "package",
"package": {
"name": "myrepo",
"version": "dev-master",
"source": {
"url": "https://github.com/me/myrepo.git",
"type": "git",
"reference": "master"
}
}
},
Run Code Online (Sandbox Code Playgroud)
但是当Composer拉出回购时,遥控器(origin和composer)就会.git/config被设置为git://github.com/me/myrepo.git.
[remote "origin"]
url = git://github.com/me/myrepo.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = git@github.com:me/myrepo.git
[branch "master"]
remote = composer
merge = refs/heads/master
[remote "composer"]
url = git://github.com/me/myrepo.git
fetch = +refs/heads/*:refs/remotes/composer/*
Run Code Online (Sandbox Code Playgroud)
我无法推动它,因为Github无法使用git://.我必须手动将其更改为https://然后推送.我https://在URL中指定了,但为什么这不受尊重?
Sel*_*aek 19
您可以使用以下命令更改用于github的协议:
composer config --global github-protocols https
Run Code Online (Sandbox Code Playgroud)
然后重新安装供应商应该做你想要的.
该github-protocols选项仅适用于 GitHub,但还有另一种解决问题的方法,该方法不依赖于将 GitHub 用于您的 Git 服务器。
您只需告诉 Composer 使用不同的 URL,就像您分叉了一个包并且希望确保 Composer 使用您的分叉而不是默认包的方式一样。
这是一个示例,我将自己的 fork 用于一个包,并强制将 URL 中的协议改为http而不是git另一个:
"repositories": [{
"type": "vcs",
"url": "https://github.com/brandondrew/laravel4-PHPExcel"
},{
"type": "vcs",
"url": "http://git.code.sf.net/p/tcpdf/code"
}],
Run Code Online (Sandbox Code Playgroud)
在 Laravel4-PHPExcel 的情况下,我很早就修复了一个错误,并且在等待维护者接受我的拉取请求时需要我的修复。(顺便说一句,他已经对他的代码进行了大量改进,所以我放弃使用我的叉子,但我在这里展示它,因为它作为示例很有用,即使我的代码不再有用在实践中。)
在 TCPDF 的情况下,它们是我的应用程序使用的唯一指定 Git 协议的包,因此当我只能使用 HTTP 代替时,乞求并恳求我客户端位置的安全团队打开端口 9418 似乎很荒谬,哪个(在我看来)他们应该开始使用。我在 URL 中所做的所有更改都是替换git为http,但它的工作方式与任何其他用户指定的 URL 一样,允许您指定 Composer 用于给定包的 URL。
更新:
为了完整起见,我觉得我应该提一下,您也可以在Git级别解决问题。对于我遇到此问题的应用程序,我觉得在 Composer 中执行此操作更合适,但您的情况可能会有所不同,因此您对这种情况的最佳方法的看法也可能不同。
Git 方法可以变得更加全球化,您可能会认为这是一个优势(或不是)。简单的情况是告诉 Git 用一个 URL 替换另一个 URL:
git config --global url."http://git.code.sf.net/p/tcpdf/code".insteadOf "git://git.code.sf.net/p/tcpdf/code"
Run Code Online (Sandbox Code Playgroud)
但是你也可以告诉 Git 总是用 'https://' 替换 'git://':
git config --global url."https://".insteadOf "git://"
Run Code Online (Sandbox Code Playgroud)
在这些例子中,我把它在用户的全局配置文件,但可以更换--global与--local把它放在仓库的配置文件(或--system把它在系统的配置文件)。
| 归档时间: |
|
| 查看次数: |
8501 次 |
| 最近记录: |