duandeng2265 2017-04-11 07:37
浏览 54
已采纳

作曲家更新后,.gitignore在Symfony 3上无法正常工作

I have two PC: A laptop and a desktop computer.
I was working two weeks on my Symfony 3 project with the desktop computer, and I defined some new parameters on my parameters.yml.dist

Today, I need to use my laptop, so I did a pull from my origin branch, and then I executed the following command to update my project:

php composer.phar update

This command updated successfully my project (parameters and vendor directory). With this, I can now run my project.

The problem is that now when I run:

git status

Lots of modified files appear in the vendor directory. Also composer.lockfile apperars, and I think that this is correct, but not the vendor files.

My .gitignorecontains, among others, the following line: vendor/*

What I did wrong? And how can I solve it?

  • 写回答

1条回答 默认 最新

  • drn61317 2017-04-11 07:58
    关注

    The problem is probably twofold.

    You probably have checked in files from the vendor directory before adding it to the gitignore or maybe you accidentally added them with the --force flag which ignores the gitignore.

    The other big problem is that you ran composer update this will not only install the dependencies in your composer.lock it will actually update them, meaning you might get different versions then the ones you were developing with before. Next time you should probably run composer install (even on a system where you already have vendors installed). This will do as advertised it will install all dependencies as defined in the composer.lock. Whenever you checkout a newer version of that file the install command will automatically update your local vendors to the versions defined there. This ensures that you always work with the same dependency versions.

    Should you want to update your dependencies you might want to do it one by one using composer update <dependency-name> this will then again update your composer.lock which you should have checked into git.

    In your case you might want to remove the vendor folder, but make sure you keep your composer.lock. Now you can commit this change to make sure you remove all checked in files vendor/. After that, your .gitignore should work again and running composer install should re-install everything as defined in the composer.lock and you should not see any changes in your work dir when running git status. If there are you might have to tweak your .gitignore, e.g. try /vendor instead of vendor/*.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关
  • ¥15 C#中的编译平台的区别影响
  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型
  • ¥15 Python 如何安装 distutils模块