<!-- THEME DEBUG -->
<!-- THEME HOOK: 'field' -->
<!-- FILE NAME SUGGESTIONS:
   ▪️ field--node--title--article.html.twig
   ✅ field--node--title.html.twig
   ▪️ field--node--article.html.twig
   ▪️ field--title.html.twig
   ▪️ field--string.html.twig
   ▪️ field.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/contrib/classy/templates/field/field--node--title.html.twig' -->
<span class=How to patch a file in a Drupal module using Command Line ">

How to patch a file in a Drupal module using Command Line

Sometimes contrib modules need a little help, whether its a bug the maintainers haven't fixed yet, or the module just isn't working with your custom code.

First, locate the code repository for the module. You can do the by going to the module's Drupal page, and clicking "Source Code" in the right sidebar. In this example we use the "group" module page as though we were going to patch this module:

1.) go to https://www.drupal.org/project/group

2.) Click "Source code"

3.) Find the correct version of your module that you are patch and note the correct tags

4.) In your Terminal Drupal root folder, go to the modules/contrib folder 

cd modules/contrib

5.) Remove the module

rm -rf group

6.) Clone the module's repo (find the url under the "Clone" dropdown button) via https:

git clone https://git.drupalcode.org/project/group.git

7.) go into the new folder

cd group

8.) Checkout the tags or version you want

git checkout tags/3.0.0-beta6

9.) Make your changes to the module's files and save

10.) create patch file

git diff > description-of-changes.patch

11.) Place the file in the composer.json file to have it apply on the next build

12.) Finally, place the patch file in your patches folder, located in the site's root folder so composer can find it. 

    "extra": {
        "patches": {

            "drupal/group": {
                "FIX THIS": "patches/description-of-changes.patch"
            },

13.) Remember to run

composer update --lock

to test out that your patch applies correctly.