[英]git/ folder not pulled on composer require
We have a private server for handling repo's of projects. 我们有一个专用服务器来处理项目的回购。 Now, following the procedure I've done a few times already, suddenly I've stumbled upon that "composer require" on one of these modules does not contain the
.git/
folder that should be there. 现在,按照我已经做过几次的步骤,突然我偶然发现这些模块之一中的“ composer require”不包含应该存在的
.git/
文件夹。
"Can happen" I thought, someone might've forgotten to include it when creating the repo. 我认为“可能发生”,可能有人忘记了在创建存储库时将其包括在内。 However, when going to
vendor/company/module
, remove the files, do git init
+ git remote add origin ssh:repo.git
+ git pull
, I come across that git add .git/
does nothing but give me the warning below: 但是,当转到
vendor/company/module
,删除文件,执行git init
+ git remote add origin ssh:repo.git
+ git pull
,我发现git add .git/
除了以下警告外什么都没有做:
$ git add .git/
warning: LF will be replaced by CRLF in .git/FETCH_HEAD.
The file will have its original line endings in your working directory.
error: Invalid path '.git/FETCH_HEAD'
error: unable to add .git/FETCH_HEAD to index
fatal: adding files failed
Thought I'd ask for if someone has an idea of how to make sure that .git/
gets included when pulling (via composer install/update/require
) from a Satis server. 以为我会问是否有人对从Satis服务器提取(通过
composer install/update/require
)时确保包含.git/
的想法。
Haven't found a solution searching SO for [git] folder
, [git] .git/ folder
or more variations over multiple pages of results. 还没有找到在
[git] folder
, [git] .git/ folder
或更多结果页面上搜索更多变体的解决方案。
Answer comes from a colleague. 答案来自一位同事。
When I was installing the package, it was just for the one package. 当我安装软件包时,它仅用于一个软件包。 Therefore I used
composer require company/project/module
to install it. 因此,我使用
composer require company/project/module
来安装它。
However, when installing the whole vendor/
folder for a project we use composer install --prefer-source -v
. 但是,在为项目安装整个
vendor/
文件夹时,我们使用composer install --prefer-source -v
。
The primary difference being the usage of --prefer-source
as the -v
flag just gives a more detailed (verbose) output in the Terminal. 主要区别是使用
--prefer-source
作为-v
标志只是在终端中提供了更详细(详细)的输出。
What I should've done was composer require company/project/module --prefer-source
我应该做的是,
composer require company/project/module --prefer-source
Went to look up as to why this did work; 想知道为什么这样做有效; following from the docs :
以下来自文档 :
--prefer-source : There are two ways of downloading a package: source and dist.
--prefer-source :有两种下载软件包的方式:source和dist。 For stable versions Composer will use the dist by default.
对于稳定版本,Composer将默认使用dist。 The source is a version control repository.
源是版本控制存储库。 If --prefer-source is enabled, Composer will install from source if there is one.
如果启用--prefer-source,则Composer将从源安装(如果有)。 This is useful if you want to make a bugfix to a project and get a local git clone of the dependency directly.
如果您要对项目进行错误修复并直接获取依赖项的本地git克隆,则此选项很有用。
========================= ========================
The reverse of --prefer-source
is --prefer-dist
; --prefer-source
的反--prefer-source
是--prefer-dist
; following from the docs 以下来自文档
--prefer-dist : Reverse of --prefer-source, Composer will install from dist if possible.
--prefer-dist :--prefer-source的相反版本,如果可能,Composer将从dist安装。 This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors.
这可以大大加快构建服务器和其他通常不运行供应商更新的用例的安装速度。 It is also a way to circumvent problems with git if you do not have a proper setup.
如果您没有正确的设置,它也是一种避免git问题的方法。
More about setting up different sources for a package (repo) in your projects can be found here . 您可以在此处找到有关在项目中为包(仓库)设置不同来源的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.