How to apply Drupal Patch

0
(0)

Obtain and apply a patch file

Download the patch file from the issue, and apply the code changes in the patch to your working directory (the following commands assume you’re in a terminal window in the project’s root directory). There are several alternatives:

  • Download the patch file manually from the issue (click the link and save to your local computer). Then:
git apply -v [patch-name].patch
  • Use curl to download the file, then use git to apply the patch:
curl -O https://www.drupal.org/files/[patch-name].patch
git apply [patch-name].patch

Or in a single line:

curl https://www.drupal.org/files/[patch-name].patch | git apply -
  • Use wget to download the file, then use git to apply the patch:
wget https://www.drupal.org/files/[patch-name].patch
git apply [patch-name].patch

Or in a single line:

wget -q -O - https://www.drupal.org/files/[patch-name].patch | git apply -
  • Set up a git alias to download and apply the patch in one command. In ~/.gitconfig:
[alias]
# Download and apply a patch.
        a = apply --index
        ac = "!f() { curl $@ | git a; }; f"

Then run git ac https://www.drupal.org/patch-url

Similar Posts:

1,065

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top