I'm having trouble with applying a patch for a Drupal module. I thought it was as simple as using "git apply thepatch.patch," but when I do this in the main directory that holds the .git directory, I get the following error message:

Checking patch entity_translation.admin.inc…
error: entity_translation.admin.inc: No such file or directory

When I do this in the directory where the files are located, nothing happens; no error is shown, but no file is changed.

It's not a problem I have with this particular patch, but I never seem to be able to apply a patch, and I just end up manually editing the files.

I would like to know the solution once and for all.

  • Did any of these solutions work for you?
    – chrisjlee
    Commented Jan 21, 2012 at 0:43

5 Answers 5


It is possible that the patch was rolled before the days of Git on drupal.org.

For old patches:

patch -p0 < thepatch.patch

For new patches that mysteriously fail with git apply:

patch -p1 < thepatch.patch

Follow below steps:

  1. Download the patch file and place it to the module folder ie. sites/all/modules/varnish
  2. Make sure you are at the same module directory ie. sites/all/modules/varnish
  3. Use git init command to start git on that repository, even if you have git initialized at drupal root.
  4. Run command git apply -v filename.patch

The command git apply -v thepatch.patch should work.

You will need to run in in the module directory which you are patching (eg. sites/all/modules/module_name/) and the .patch file should be in that directory as well. The -v option is for verbose and should tell you whether the patch application was successful.

  • is just doesn't, tried a couple other patches but nothing ever happens.
    – dazz
    Commented Oct 21, 2011 at 8:55
  • Adding to @nmc comment, that your directory sites/all/modules does not have to be under version control. but you should have git installed.
    – saadlulu
    Commented Dec 25, 2012 at 12:18

The instructions given for each project hosted on Drupal.org are the following (you can find them on this page, for example):

Applying a patch

Download the patch to your working directory. Apply the patch with the following command:

git apply -v [patchname.patch]

To avoid accidentally including the patch file in future commits, remove it:

rm  [patchname.patch]

The working directory is the directory containing the module files; in the case of the Views module, it's the directory containing the views.module, views.info, and views.install files you need to patch.


I had the same issue, in my case, the following worked for me.

patch -p1 < thepatch.patch

  • According to this page drupal.org/patch/apply you should use patch -p1 < thepatch.patch "If you are not using git, or if the repo isn't a local checkout of the project you wish to patch" Commented Jul 11, 2016 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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