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?
Command line Git repository delete Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains.
A . git folder is required to log every commit history and every other information required for your remote repository, version control, commits etc. These things are saved in different folders which have different meanings. Once the folder is created, open it and see the contents of the folder.
Just delete . git directory and it will be all. Actually, as far as a file manager (windows file explorer or nautilus etc) is concerned, a git repo is just a directory.
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
.
Using --prefer-dist is the only native solution, but there will be situations where there is simply no packaged version available, and in those cases Composer will still fall back to git clones.
The only workaround I know of is to run a cleanup script after composer install that removes Git directories. Maybe a command like this:
find . -type d | grep .git | xargs rm -rf
Be careful to run this in your vendor directory, not your root directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With