简体   繁体   中英

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.

"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:

$ 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.

Haven't found a solution searching SO for [git] folder , [git] .git/ folder or more variations over multiple pages of results.

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.

However, when installing the whole vendor/ folder for a project we use 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.

What I should've done was 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. For stable versions Composer will use the dist by default. The source is a version control repository. If --prefer-source is enabled, Composer will install from source if there is one. This is useful if you want to make a bugfix to a project and get a local git clone of the dependency directly.

=========================

The reverse of --prefer-source is --prefer-dist ; following from the docs

--prefer-dist : Reverse of --prefer-source, Composer will install from dist if possible. 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.

More about setting up different sources for a package (repo) in your projects can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM