如何使composer不为包创建.git目录 [英] How to make composer NOT create a .git directory for a package
问题描述
我找到了一些相关的帖子,但那些并没有真正回答我的问题。
假设我想安装这个软件包:
https://github.com/pear/ Net_Socket
摘自我的composer.json:
config:{
preferred-install:dist
},
repositories:[
{
键入:vcs,
url:https://github.com/pear/Net_Socket.git
}
],
require:{
pear / net_socket:*,
}
}
所以我需要它在没有.git目录的情况下安装,因此它在我的项目中不被视为子模块。
像其他人说的那样,我如何让它下载dist版本?如果一个包被看作是一个git子模块,那么你还没有排除
code> vendor 文件夹从提交到您自己的存储库。建议将供应商文件夹添加到 .gitignore
中,而不是提交这些文件,只提交 composer.lock
(和 composer.json
当然)。
除此之外,运行 composer install - -prefer-dist
应该完成这项工作。请注意,如果稍后改变主意,Composer似乎不会更改首先使用的下载方法。如果Composer检测到克隆的repo,只需更新即可,而不是下载ZIP并将其解压缩。如果你想改变它,删除整个 vendor
文件夹并运行 composer update --prefer-dist
。
I found a couple related posts, but those don't really answer my question. Let's say I want to install this package: https://github.com/pear/Net_Socket
an excerpt from my composer.json:
{
"config": {
"preferred-install": "dist"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pear/Net_Socket.git"
}
],
"require": {
"pear/net_socket": "*",
}
}
So I need it to be installed without the .git directory so it is not seen as a submodule in my project. How do I make it download a "dist" version, like others said? Do I have to tag a commit?
If a package is seen as a git submodule, you haven't excluded the vendor
folder from being committed to your own repository. It is recommended to add the vendor folder to .gitignore
, and not commit these files, only commit composer.lock
(and composer.json
of course).
Apart from that, running composer install --prefer-dist
should do the job. Note that Composer seems to not change the download method used first if you change your mind later. If Composer detects a cloned repo, it is faster to just update that instead of downloading a ZIP and unpacking it. If you want to change that, delete the whole vendor
folder and run composer update --prefer-dist
.
这篇关于如何使composer不为包创建.git目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!