How to avoid composer discard changes message

2019-02-03 03:21发布

I'm updating symfony verdors via composer. I always do it using:

php composer.phar update

But recent version of composer, before update each package show a message like this:

  - Updating doctrine/data-fixtures dev-master (a95d783 => a28b6bd)
The package has modified files:
M .gitignore
M .gitmodules
M LICENSE
M README.md
M UPGRADE
M composer.json
M lib/Doctrine/Common/DataFixtures/AbstractFixture.php
M lib/Doctrine/Common/DataFixtures/DependentFixtureInterface.php
M lib/Doctrine/Common/DataFixtures/Event/Listener/MongoDBReferenceListener.php
M lib/Doctrine/Common/DataFixtures/Event/Listener/ORMReferenceListener.php

-10 more files modified, choose "v" to view the full list Discard changes [y,n,v,s,?]?

How to avoid this?

4条回答
闹够了就滚
2楼-- · 2019-02-03 03:59

both @lemats and @reza-sanaie's answers are incomplete as --no-interaction (-n) composer's option is required to have a real update without any question (see https://github.com/composer/composer/pull/1188#issuecomment-16011533).

So after

php composer.phar config --global discard-changes true

or after modifying composer.json

"config": {
    "discard-changes": true
},  

use

php composer.phar update -n
查看更多
Explosion°爆炸
3楼-- · 2019-02-03 04:08

Alternative to @lemats solution you can modify the composer.json file with:

  "config": {
      "discard-changes": true
  },  

It's worth nothing for this option to kick in you have to be running in --no-interaction mode

php composer.json install --no-interaction

Although I agree with @Seldaek on you shouldn't be modifying these vendor files, but sometimes you are forced to monkey patch it :(

查看更多
【Aperson】
4楼-- · 2019-02-03 04:19

How about not modifying vendor files? If they get modified most likely it's because of some messed up git settings for the line endings. See https://help.github.com/articles/dealing-with-line-endings

查看更多
该账号已被封号
5楼-- · 2019-02-03 04:22

Set composer config to discard changes (see: https://github.com/composer/composer/pull/1188):

php composer.phar config --global discard-changes true
查看更多
登录 后发表回答