Home > source control > Git Patch to SVN Patch

Git Patch to SVN Patch

I have to work with SVN at my current job, but my favorite source control is Git. To enjoy my work I’m using locally Git repository and remotely centralized SVN one. There is many guides how to do it, here is one of them: Effectively Using Git With Subversion.

We have to follow pre-commit code review rule, so we are doing it by publishing patches. Unfortunately, merge tool from Windows’ Tortoise SVN does not recognize patches created by Git, wich on the other hand are properly recognized by unix tools like patch. To make it all work, I created simple Ruby script to convert Git patch to SVN patch standard.

Link to this script can be found here.

Usage is as follows:

git2svn.rb git.patch
Advertisements
Categories: source control Tags: ,
  1. nazgob
    January 7, 2011 at 22:00

    pre-commit review lol, sounds like a bad place to be 🙂

  2. January 8, 2011 at 12:56

    no comments, maybe you’ll tell me? 🙂

  3. March 22, 2012 at 23:02

    Thanks a lot! Worked like a charm.

  4. anon
    June 13, 2013 at 07:21

    Is there something similar for converting svn patch to git patch? 🙂
    Would be really useful!!!

    • October 29, 2013 at 13:15

      Maybe it will be simpler if you could use git-svn?

  5. Jens
    October 29, 2013 at 12:52

    I tried this out and got:

    …/gitp2svnp.rb:17:in `gsub!’: invalid byte sequence in UTF-8 (ArgumentError)
    from …/gitp2svnp.rb:17:in `block (2 levels) in ‘
    from …/gitp2svnp.rb:16:in `each’
    from …/gitp2svnp.rb:16:in `block in ‘
    from …/gitp2svnp.rb:14:in `open’
    from …/gitp2svnp.rb:14:in `

    Yes, if I set a locale matching the encoding of the patch, it works. But is this really necessary just for conversion?

    • October 29, 2013 at 13:14

      I modified script to force reading in utf-8 format. You can download it and try again. Then you can tell me if it works now.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: