![](/img/trans.png)
[英]Should I check in libraries in the vendor folder that are pulled in by composer?
[英]git/ folder not pulled on composer require
我們有一個專用服務器來處理項目的回購。 現在,按照我已經做過幾次的步驟,突然我偶然發現這些模塊之一中的“ composer require”不包含應該存在的.git/
文件夾。
我認為“可能發生”,可能有人忘記了在創建存儲庫時將其包括在內。 但是,當轉到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
以為我會問是否有人對從Satis服務器提取(通過composer install/update/require
)時確保包含.git/
的想法。
還沒有找到在[git] folder
, [git] .git/ folder
或更多結果頁面上搜索更多變體的解決方案。
答案來自一位同事。
當我安裝軟件包時,它僅用於一個軟件包。 因此,我使用composer require company/project/module
來安裝它。
但是,在為項目安裝整個vendor/
文件夾時,我們使用composer install --prefer-source -v
。
主要區別是使用--prefer-source
作為-v
標志只是在終端中提供了更詳細(詳細)的輸出。
我應該做的是, composer require company/project/module --prefer-source
想知道為什么這樣做有效; 以下來自文檔 :
--prefer-source :有兩種下載軟件包的方式:source和dist。 對於穩定版本,Composer將默認使用dist。 源是版本控制存儲庫。 如果啟用--prefer-source,則Composer將從源安裝(如果有)。 如果您要對項目進行錯誤修復並直接獲取依賴項的本地git克隆,則此選項很有用。
========================
--prefer-source
的反--prefer-source
是--prefer-dist
; 以下來自文檔
--prefer-dist :--prefer-source的相反版本,如果可能,Composer將從dist安裝。 這可以大大加快構建服務器和其他通常不運行供應商更新的用例的安裝速度。 如果您沒有正確的設置,它也是一種避免git問題的方法。
您可以在此處找到有關在項目中為包(倉庫)設置不同來源的更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.