Applying a patch
Navigate into your Nextcloud server’s root directory (contains the
Now apply the patch with the following command:
patch -p 1 < /path/to/the/file.patch
There can be errors about not found files, especially when you take a patch from GitHub there might be development or test files included in the patch. when the files are in build/ or a tests/ subdirectory it is mostly being
Navigate to the root of this app (mostly
apps/[APPID]/), if you can not find the app there use the
sudo -u www-data php occ app:getpath APPIDcommand to find the path.
Now apply the patch with the same command as in Patching server
Reverting a patch
Navigate to the directory where you applied the patch.
Now revert the patch with the
patch -R -p 1 < /path/to/the/file.patch
Getting a patch from a GitHub pull request
If you found a related pull request on GitHub that solves your issue, or you want to help developers and verify a fix works, you can get a patch for the pull request.
Using https://github.com/nextcloud/server/pull/26396 as an example.
.patchto the URL: https://github.com/nextcloud/server/pull/26396.patch
Download the patch to your server and follow the Applying a patch steps.
In case you are on an older version, you might first need to go the the correct version of the patch.
You can find it by looking for a link by the
backportbot-nextcloudor a developer will leave a manual comment about the backport to an older Nextcloud version. For the example above you the pull request for Nextcloud 21 is at https://github.com/nextcloud/server/pull/26406 and the patch at https://github.com/nextcloud/server/pull/26406.patch