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/*.

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

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站