Andrew Fletcher published: 27 May 2020 1 minute read
As a process I apply patches locally first, then using git upload the update(s) to a development site on the server. Once the testing has been completed, the final step to apply the patch to the production site.
Using Terminal or your preferred shell program, navigate to the correct directory. Then run this command using the name of the patch file (example.patch):
patch < example.patch
However, if you are patching Drupal core then remember to patch from the root directory and use the -p0 to patch. This will stop patch from asking you which file you wish to patch:
patch -p0 < example.patch
If your patch uses a & b directories in the patch, you can use the -p1 to get rid of the a & b directories.
patch -p1 < example.patch
Most of my patches are to core in making minor tweaks.
Related articles
Andrew Fletcher
•
09 May 2024
Accessing nested paragraph fields in Drupal: a step-by-step reference
The issue – I have a content type that includes an entity reference revisions field named field_introduction. This field points to a paragraph, which itself contains a text field also named field_introduction, of the type Text (formatted, long). How can I access the content stored in this...
Andrew Fletcher
•
09 May 2024
How to retrieve the current menu title in Drupal – a developer’s reference
When building a theme in Drupal, it's often necessary to adapt your site’s UI dynamically based on the context in which a user is navigating. One such piece of dynamic content is the menu title. Achieving this can be a bit tricky due to the layered nature of its routing and menu systems. This...
Andrew Fletcher
•
09 May 2024
Efficiently managing large file archives in Linux: excluding directories with Zip
Managing large directories, especially those filled with a diverse mix of media such as documents and images, can quickly become cumbersome. In my latest project, dealing with a directory that totals a whopping 87GB, the need for efficient file compression and selective archiving became apparent....