SVN Patch

If you don't have commit rights to a repository or if you aren't ready to commit code to the repository but want to share it with others, you can create a patch. The following instructions assume that you have checked out a copy of the code from the repository and made your changes if you are creating a patch.

Note: It is good advice to always read through a patch before applying it.

Command line

Creating a patch

Run the following command in the project root directory:

svn diff > ~/[name_of_file.diff]

If you have changes you don't want to be part of the patch, you can specify a specific file/directory to be included in the patch:

svn diff directory1/ > ~/[name_of_file.diff]

or even specify multiple files or directories:

svn diff directory1/ directory2/ > ~/[name_of_file.diff]

After a patch file is created, attach it to the corresponding ticket in Jira.

Here is a short tutorial that shows how to create a patch:

Applying a Patch

Once you've read through the patch, go to the root of your project and type the following:

patch -p0 -i ~/[name_of_file.diff]

Test your patch before committing changes to the repository.

Video Tutorial

You can watch these steps demonstrated in a tutorial video on youtube.

TortoiseSVN (Windows)

The TortoiseSVN documentation includes instructions for creating and applying patches.

Creating a patch

  • Find the root directory of the project in Windows Explorer.
  • Right-click on the project directory and choose TortoiseSVN > Create patch... from the menu
  • On the Create Patch window, select the files that should be included in the patch and then click OK
  • Specify the name and location where the patch file should be created on the Save as...' window
  • The contents of the patch file will be displayed in a TortoiseUDiff window

Applying a patch

  • Find the root directory of the project in Windows Explorer.
  • Right-click on the project directory and choose TortoiseSVN > Apply patch... from the menu
  • Select the patch file to be applied and click Open
  • The TortoiseMerge window will appear along with a small window with a list of changed files

You can double-click a file in the list to open the file in TortoiseMerge. This will open the original file and the patched file side-by-side so that you can review the changes. You can review the changes and make modifications, if necessary. When you are finished with the file, press Ctrl-S or click the Save button to save the patched file. Complete this process for each file in the patch.

You can also apply the patch to specific files or all files without reviewing the patch by right-clicking a file in the patch list and choosing Patch all or Patch selected. This will patch and save the specified files.

This page was last modified on 23 December 2011, at 13:51.

Note: Content found in this wiki may not always reflect official Church information.