How to create a patch and apply it with subversion

If you want to create a patch with svn you only have to type in the terminal something like:

svn diff yourproject > yourproject.patch

Where yourproject is the folder containing the modified source code.

Then, to restore the patch (apply the changes stored in patch in a new working copy), copy the patch file yourproject.patch in the machine where you want apply the patch and "cd "to the parent folder containing the yourproject folder (not inside yourproject). Then type:

patch -p0 -i /path/to/yourproject.patch

If you do not respect the same hierarchy when creating and applying the patch then you'll have to play around with the "p0" parameter (gives the entire file name unmodified). Of course the patch command is not related to SVN and you can use it in many other environments.

Without subversion

If you are not a subversion user this is how general patchind is done:

diff -Nur old_file new_file > patchfile

And then apply:

patch old_file patchfile