Jan 22, 2014

How to create and apply a patch from an SVN Commit

Posted Jan 22, 2014
In subversion, there are cases that you may want to apply the same commit to another folder. E.g. you have a similar branch of your source code and you have committed the changes in your main branch. For this case, rather than copying your codes manually, you can create a patch from your SVN commit and apply it to another directory using the ff:

Create a patch from your commit, get the difference between two svn commits. Usually it's just your [desired commit #] minus one:
svn diff -r [reference commit]:[desired commit] > [filename]
e.g.
svn diff -r 9714:9715 > 9715.patch


Copy the patch file to the directory you want to apply it and go to that directory in the command line and type:
patch -p0 < [filename]
e.g.
patch -p0 < 9715.patch 

No comments:

Post a Comment