Composer - uncommited changes (symfony 2.1)

You can use composer status -v. Here's how you can detect a file change in vendor/ using this command, and how to fix it.

First, we verify that no package is modified:

➜  SymfonyApp git:(master) ✗ composer status
No local changes

Then, we change a vendor file

➜  SymfonyApp git:(master) ✗ echo "modification" >> vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php

We then ask composer to tell us about modified vendor files (note the -v option, to see the modified files)

➜  SymfonyApp git:(master) ✗ composer status -v
You have changes in the following dependencies:
/Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony:
    M src/Symfony/Component/HttpKernel/Kernel.php

We then reset the vendor git repository to set the files back to their original state.

➜  SymfonyApp git:(master) ✗ cd /Users/adrienbrault/Developer/SymfonyApp/vendor/symfony/symfony
➜  symfony  git checkout .
➜  symfony  cd -
~/Developer/SymfonyApp

Finally, we check that the files are not seen as modified anymore by composer.

➜  SymfonyApp git:(master) ✗ composer status -v
No local changes

Update: composer should now help you to handle this


You can also set the discard-changes to true in the config parameter of your composer.json file, see https://getcomposer.org/doc/06-config.md#discard-changes.

{
  "name": "test",
  "description": "Demonstrating concepts",
...
  "config": {
    "process-timeout": 1800,
    "discard-changes" : true
  },
...
}

Because this affected various projects sharing dependencies on one server, since for example a vender author would ask me to test quick changes before filing bugs and committing to their repo, I ran this to globally set discard-changes to true:

php composer.phar config -g  discard-changes 1