Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Do you need to add the vendor directory to version control?

Shulou Source: shulou.com Published: 2022-06-02 18:51:21 10月05日 Update

Editor to share with you the need to add the vendor directory to version control, I hope you will learn a lot after reading this article, let's discuss it together!

Should I add the vendor directory to version control?

In general, please do not do this. The vendor folder (or other location where your dependent package is installed) should be added to .gitignore / svn:ignore/.

The best way is for all developers to use the Composer command to install dependencies. Similarly, build servers, deployment tools, etc., need to include running Composer as part of the project boot.

Although it is attractive to submit it to the version library in some cases, it can easily lead to the following problems:

● when you update the code, the version control repository code gets bigger and the diff becomes bloated.

All dependencies of the ● project will produce a copy in your version control.

● git repositories installed by Composer through git in some scenarios will be treated as sub-modules. This is problematic and troublesome because they are not really submodules.

If you really feel you have to do this, you have these options:

1. The version of the dependent package is limited to the released (non-dev) version that has been hit by tag, so that you will only install it through zipped to avoid problems caused by git submodule.

2. Use-prefer-dist or set preferred-install to dist to the config of your project.

3. Remove the .git directory after each dependency installation, and then add them to your repository. You can use rm-rf vendor/**/.git (in ZSH) or find vendor/-type d-name ".git"-exec rm-rf {}\; (in Bash). But this means that you need to remove these dependencies the next time you run composer update. /

4. Add a .gitignore rule (/ vendor/**/.git) to ignore the .git directory under vendor. The advantage of this approach is that you don't have to delete these dependencies for the sake of composer update.

After reading this article, I believe you need to add the vendor directory to version control do not have a certain understanding, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: Version catalog control warehouse code situation module article problem project run bloated in that case people location several problems copies commands scenarios benefits Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi OPPO Reno Linux vpn