Drupal Apply Patch Manually

Applying a Patch Manually; Making a Drupal patch with Git (also covers applying) HowTo: How to apply a patch to a contributed module - Beginner's version (Windows) Apply Patches on Windows (more methods) Apply patches on Mac OS; How to apply patches for Drupal modules and files. This lesson takes a look at applying a patch from Drupal.org to your local copy of a module or Drupal core using Git. Afterwards we'll look at how you can create your own patches, using git diff and git format-patch, in order to contribute code back to Drupal or any of the module's on Drupal.org.

Active1 year, 4 months ago

I'm trying to apply a patch that includes binary files with git apply but only the files are added. I tried running git apply failing.patch -v and it prints something like:

  1. Applying a patch manually. You could use a patch program to apply a patch, but you do not need to. Doing it manually is perfectly okay, and might give you a better idea of what is going on in your code. Smaller patches are easier to do than large ones, and yet, if you are careful, you can manually apply a patch regardless of the size of the patch.
  2. How to Patch Drupal Modules. Apply a Patch. If this is the case you may find it quicker to edit the files manually. Test a Patch.
Drupal Apply Patch Manually

Skipped patch 'file.txt'.
Checking patch file.bin...
Applied patch file.bin cleanly.

How can I find out what's the reason of the skip? As the current message is not very enlightening.

Iulian OnofreiIulian Onofrei
4,4473 gold badges45 silver badges83 bronze badges

3 Answers

I found out the problem by running patch -p1 < failing.patch which printed:

Apply

can't find file to patch at input line 5

and reminded me that I was not in the root directory.

I can't understand why no one had asked this before and why is the verbose message not verbose.

Also, not even the official documentation mentions skipping and possible causes.

Iulian OnofreiIulian OnofreiDrupal Apply Patch Manually
4,4473 gold badges45 silver badges83 bronze badges

Suffering this issue whilst attempting to port changes across projects. git apply seems to ignore any directory names on the patch file paths, also it refuses to apply if the Index line does not match a file hash in the target repository. I had better success using these options (of which --no-index seems to be undocumented):

Ed RandallEd Randall
3,4471 gold badge31 silver badges32 bronze badges

Drupal 8 Patch

Got the same issue. In my case the source of error was .git folder in some of parent directories of the patch target. The solution was to move patch target outside that parent directory.

Drupal Apply Patch Manually Download

AlexanderAlexander

Not the answer you're looking for? Browse other questions tagged gitpatch or ask your own question.