I'm using the ZF2 skeleton app and it has a .gitignore that prevents external libraries from being commited to git. While debugging I like to go and change stuff here and there in the libraries' source to learn how things work. If these were version controlled it would be very easy to revert them back to their original state.
How can I force Composer to reinstall a particular framework so that I can get a fresh -unmodified- copy again?
PS: Please don't suggest removing the .gitignore file since it's there for a reason; it prevents my third party libraries from getting into my app's repository. I can always install them during an automated deployment.
What I did:
composer update --prefer-source vendor/library-name
It fetches the library again along with it's git repo
Just clear your vendors folder
As user @aaracrr pointed out in a comment on another answer probably the best answer is to re-require the package with the same version constraint.
ie.
or specifying a version constraint
Reinstall the dependencies. Remove the vendor folder (manually) or via rm command (if you are in the project folder, sure) on Linux before:
https://www.dev-metal.com/composer-problems-try-full-reset/
You can use the
--prefer-source
flag for composer to checkout external packages with the VCS information (if any available). You can simply revert to the original state. Also if you issue thecomposer update
command composer will detect any changes you made locally and ask if you want to discard them.Your .gitignore file is related to your root project (ZF2 skeleton) and it prevents the vendor dir (where your third party libs are) from committing to your own VCS. The ignore file is unrelated to the git repo's of your vendors.
I didn't want to delete all the packages in
vendor/
directory, so here is how I did it:rm -rf vendor/package-i-messed-up
composer install
again