How to apply SVN diff to git?

I have my projects in 2 repositories. One under SVN and one under Git. Whenever I change something in SVN, I want to do the same in the Git repository.

Let's say I make changes to the SVN repository by creating version 125. How would I apply the same changes to my Git repository (assuming my Git repository is updated to version 124).

Thank.

+47
git version-control svn patch
Mar 18 '09 at 18:07
source share
6 answers

What I actually did / looked for was:

cd /path/to/svn/repo svn diff -r 125 > /tmp/patch.diff cd /path/to/git/repo patch -p0 < /tmp/patch.diff 
+46
Mar 18 '09 at 18:17
source share

Try:

 svn diff | patch -d /path/to/git/repo -p0 

See svn help diff if you want to export a specific version of diff.

+18
Mar 18 '09 at 18:13
source share

Why doesn't anyone like git-svn? I can not assume that no one knows about this.

There is git-svn (and git-hg and git-cvs and git-bzr afaict). At least with git-svn you can just do

 git svn clone --stdlayout http://myrepo/root here 

using -s ( --stdlayout ) assumes a standard connecting line / branches / tags / layout, but you can have one anyway ( man git-svn ).

The display is bidirectional, so you can click and drag like on a native (git) remote. No questions.

+5
Mar 16 2018-11-11T00:
source share

If you intend to create a patch in SVN and apply it with Git later, be sure to use the --git command-line option :

--git

It includes a special output mode for svn diff, designed for cross-compatibility with the popular distributed version control of the Git system.

For example, run

svn diff --git -r 125 > /tmp/patch.diff

+4
Jul 29 '16 at 10:44
source share

In addition to using the patch, as mentioned above, you can also consider installing a post-commit hook so that you don’t have to do this every time you do something new.

+2
Mar 21 '09 at 12:12
source share

Below I worked for me.

Source: How to create and apply a patch using Git

First, see what changes have been made to the patch . You can do it easily with git apply

 git apply --stat fix_empty_poster.patch 

Please note that this command SHOULD NOT apply the patch, but only shows statistics about what it does. After viewing the patch file with your favorite editor, you can see what the actual changes are.

Next, you are interested in how unpleasant the patch will be . git allows you to test a patch before actually applying it.

 git apply --check fix_empty_poster.patch 

If you do not get any errors, the patch can be applied cleanly . Otherwise, you can see what problem you are facing.

To apply the patch, use git am instead of git. The reason for this is that git am allows you to sign the application patch. This may be useful for future reference.

 git am --signoff < fix_empty_poster.patch Applying: Added specs to test empty poster URL behaviour Applying: Added poster URL as part of cli output 

Well, the fixes were applied cleanly, and your main branch has been updated. Of course, repeat the tests to make sure nothing is broken.

In the git log, you will find that the commit messages contain an "Connected" tag. This tag will be read by Github and others to provide useful information on how the commit ended in code.

0
Jul 29 '16 at 9:16
source share



All Articles