为什么 Symfony/Git 忽略某些文件夹?
我刚刚注意到,当我将我的 Symfony 项目推送到 Gitlab 时,某些文件夹(例如“vendor”)不会被推送(因为它们被 .gitignore 忽略)。
这是为什么呢?如果我想将项目从 Gitlab 克隆到我的另一台计算机上,那么我会丢失供应商文件夹,这不是有问题吗?
I just noticed that when I push my Symfony project to Gitlab, some of the folders (for example "vendor") are not pushed (because they are ignored by .gitignore).
Why is this? And isn't it problematic if I then want to clone the project from Gitlab onto my other computer, where I then would be missing the vendor folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,您不想在 git 中包含供应商文件夹,因为在部署时可以通过保存composer.lock文件来重建该文件夹。
您的部署应使用 Composer install 来构建供应商目录,并且它将使用与源提交中由 Composer 安装的文件相同的文件。
总结:
composer update
。composer install
composer install
,因此如果需要,您可以在每次 git pull 时运行它。它应该与 git repos 具有幂等性。composer install --no-dev
这将省略任何开发库,但是,拥有一个临时环境以确保您已经在某个地方实际测试了该构建非常重要。您可能需要研究并考虑生产部署的这些附加选项:composer install --no-dev --no-scripts --optimize-autoloader。Typically you don't want to include the vendor folder in git, as that can be rebuilt when you deploy by saving your composer.lock file.
Your deploy should use
composer install
to build the vendor directory, and it will use the same files as those installed by composer in your source commit(s).In summary:
composer update
.composer install
composer install
can be done whenever you would like, so you can run it everytime you git pull if you want. It should be idempotent with git repos.composer install --no-dev
This will omit any development libraries, however, it is important to have a staging environment to insure you've actually tested that build somewhere. You might want to research and consider these additional options for a production deployment:composer install --no-dev --no-scripts --optimize-autoloader
.