Click here to Skip to main content
15,883,705 members
Articles / All Topics

Creating and Applying Patch in SVN

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
5 May 2015CPOL3 min read 10.3K   4   1
Creating and applying Patch in SVN

In this post, I am going to explain something about patch files in SVN. Let me explain what a patch is ?
A patch is text file that contains the modification that were made to a file.

Why is this useful? I got some points where I found it useful.

  1. Let us suppose we are in a condition where we have made some changes to some file and we want other developers to know about the changes that we did to the specific file without committing the file. In a situation like this, we can create the patch of that file and give this patch file to other developer so that he/she can see the changes that we have made.
  2. Can use the undo option to undo the changes, but that can be a very hectic process. So in a situation like this, Patch can be very helpful. If we have the patch of that file stored, then we can simply apply patch to get all the changes back that we lost by mistake.

We can also create patch of more than one file and can apply all those patch at once.

Let's create a patch and then apply patch:

How to create a patch

First of all, let's make some changes to a file. For now, I am going to add one dummy function in some file named as ImportDefault.js.

Now, let's create patch of this file. We can right click on the modified file and select option Tortoise SVN and then choose Create patch option.

Select Create Patch Image

It will open a window where we can choose for which file we are going to create a patch. We can also set the constraints while making patch for a file by clicking on option button.

savepatchlocationEdit (1)

Let's not bother about it and click OK. It will open another window which will ask us to choose the location where patch file should be stored. We will save it in desktop.

DiffOptions

We can see how the patch file will look. It has all the information regarding the modifications that we have made.

PatchCopy

As we can see, we had added one function in our file and it's clearly visible in patch file in New Modification Section.

Now let's revert the file. As we see now, we have lost all the changes. So for getting those changes back, we shall apply the patch.

Apply Patch: Now just right click on patch file and select TortoiseSVN option and then choose Apply Patch.

Choose Apply Patch Option

Now, it will ask you the location where you want to patch the file so we choose the same location where our file is stored. Now we click ‘Select Folder’ option.

applypatchlocationEdit (1)

It will now open another window where we can choose files to which we want to apply the patch option. Select our file and click on patch selected item.

ChooseFolderToPatch

After clicking on patch selected item, we see that we have got our changes back. It also shows one file that will show the difference between the original and the modified file.

PatchApplied

Now, we can see that the file we had reverted now has all the changes previously made by us.

I hope you like the post. :)

Image 9 Image 10

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Mindfire Solutions
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralApplying patch in SVN Pin
Member 114143866-May-15 21:47
Member 114143866-May-15 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.