Wednesday, April 1, 2009

How to apply/create an svn patch (for beginners)

To apply an svn patch (your_patch_file.patch) go to the root of your source directory, and place the patch there. (or you can specify the location of the patch with the patch name if it is not placed in the root of the source tree.)
patch -p0 < your_patch_file.patch
Similarly if you have modified the source tree, and want to create a patch for the changes that you made, from the source root:
svn diff > your_patch_file.patch
or giving the files/folders that you need to get the diff of, along with their relative path.
svn diff > path1/file1 path2/file2 path3/file3 > your_patch_file.patch

your_patch_file.patch will be created inside the root of the source tree. (You may specify the location too, as usual)

Similarly,
How to get the svn diff between two commits?

svn diff -r 5224:5225 > your_patch_file.patch
gets the commit 5225 for the particular directory.

svn diff -r oldversion:newversion files > your_patch_file.patch
gets the diff between the commits newversion and oldversion.

4 comments:

  1. Thank you for the great post, it was very useful because I couldn't get it working with my eclipse plugin (:

    ReplyDelete
  2. Hi Christy,
    Glad to know that you found this post useful.

    Regards,
    Pradeeban.

    ReplyDelete