How do we correctly patch our core and modules in drupal?
First, run
Composer require cweagans/composer-patches
Now you have a package installed that enables you to patch core, libraries or modules.
Second, add a patch to a folder named 'patches' in the root (where your composer.json file is).
Third, add an "extras" section in composer with a patch:
"extra": {
"patches": {
"drupal/core": {
"Undocumented title variable in feed-icon.html.twig": "patches/3156260-11.patch"
}
},
}
Fourth, run
composer install
This will remove the core, re-download and patch it. Same goes for modules and libraries.