in

CodePrairie .NET

South Dakota .NET User Group

chrisortman

Creating Subversion patches with git

Adam expressed his frustration with creating tortoise compatible patches using git.

He mentions a script that will do the job, which I have not yet tried. However if you are using git on windows you most likely have cygwin installed which you can use to install the patch.exe program.

But first you need a patch file.

This is pretty simple

In my example I'm going to be creating a patch to fix FACILITIES-97 in castle project.

First I need my local git repo ready

git co -b bugs/facilities-97 castle-svn/trunk

Now edit / test

When you're all done prepare your index and commit

git add .
git commit -m "fixes (FACILITIES-97)"

Now create your patch

git format-patch castle-svn/trunk

That last command will create a patch file for every commit that is in bugs/facilities-97 but not in castle-svn/trunk
In this case I have a single commit so it creates 0001-fixes-FACILITIES-97.patch

Now that you've got your patches they can be applied to svn like this

patch -p1 -i 0001-fixes-FACILITIES-97.patch

Now here's the gotcha. patch.exe can either read stdin or take a named file. My patches would always fail if I used stdin, so using -i to specify the filename is important.
The -p1 switch tells patch to strip the first part of the path in the patch file because git generates file paths like
/a/InversionOfControl/MicroKernel.....

That's it, you're all done.

Published Jan 14 2008, 10:26 PM by chrisortman
Filed under: ,

Comments

 

Adam Tybor said:

Thank you! I will have to try this Chris.

January 15, 2008 7:57 AM
 

The Random Musings » Blog Archive » links for 2008-07-18 said:

Pingback from  The Random Musings  » Blog Archive   » links for 2008-07-18

July 17, 2008 8:32 PM
 

Apply Git Patches to SVN Repository | { Ben.Ramey; } said:

Pingback from  Apply Git Patches to SVN Repository | { Ben.Ramey; }

September 23, 2014 1:27 PM

Leave a Comment

(required)
(optional)
(required)
Add
Powered by Community Server (Commercial Edition), by Telligent Systems