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?

图片转代码服务由CSDN问答提供 功能建议

我有两台PC:一个 laptop 和一个台式计算机
我用我的桌面计算机在我的Symfony 3项目上工作了两周,我在我的参数上定义了一些新的参数。参考文献

今天,我需要 使用我的笔记本电脑,所以我从我的原始分支拉了一下,然后我执行了以下命令来更新我的项目:

  php composer.phar update 

此命令成功更新了我的项目(参数和供应商目录)。 有了这个,我现在可以运行我的项目。


  git status \  n   

许多修改过的文件出现在 vendor 目录中。 另外 composer.lock 文件的出现者,我认为这是正确的,但不是供应商文件。

我的 .gitignore 包含 ,其中包括以下行: vendor / *

我做错了什么? 我该如何解决?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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

    打赏 评论

相关推荐 更多相似问题