Create diff patch from Composer /vendor to apply to Git repository

If you’ve accidentally made changes to a package in the /vendor directory of your project, you’ll need to apply these same changes to the Git repository that the package comes from (or fork it and patch it, etc.) before Composer overwrites the updates.

The easiest way to do this is to create a diff patch which you can then apply to the package repository. You need to make sure it’s relative to the package root for when you apply the patch.

cd vendor/PackageName/
git diff > changes.diff

Then go into the Git repository (or fork) of the package and apply the patch.

cd RepositoryName/
git apply --ignore-space-change --ignore-whitespace changes.diff

Add comment