Here is my answer, i hope it will help someone:
First make sure that this package is installed via composer: cweagans/composer-patches
Lets say you want to apply a patch from a third-party module installed via composer for a controller. Please make sure that you have this part in the composer.json file:
"extra": {
"magento-force": true,
"composer-exit-on-patch-failure": true,
"patches": {
"vendorname/module-somerandomname": {
"Description here": "patches/my_patch_name.patch"
}
}
},
Assuming that your vendor folder is in the .gitignore file, you can still do:
git add -f vendor/vendorname/module-somerandomname/Controller/Myfile.php
- Do your changes to the Myfile.php
- Do a
git diff vendor/vendorname/module-somerandomname/Controller/Myfile.php > patches/my_patch_name.patch
git restorereset --stagedHEAD vendor/vendorname/module-somerandomname/Controller/Myfile.php
- Do a
composer install