简体   繁体   English

如何将SVN中的提交重播到git

[英]How do I replay commits in svn to git

I need to recreate some commits from one git repository to another that are seemingly unrelated. 我需要重新创建一些从一个git存储库到似乎无关的提交。 The situation is as follows: 情况如下:

Repository 1 is a git-svn repo that contains the commits I want to replay into the other. 仓库1是一个git-svn仓库,包含我想重播到另一个的提交。 Contentwise it's a collection of patches that were created in a support branch since we tagged a release. 从内容上讲,这是自我们标记发行版以来在support分支中创建的补丁程序的集合。

Repository 2 is a normal git repository that was created from our old svn repository (same as repo 1) and it also contains the tagged release as a git tag 仓库2是一个普通的git仓库,是从我们以前的svn仓库(与仓库1相同)创建的,它还包含带有git标签的已标记发行版

Ultimately, what I want to achieve is recreate the patch-branch from the old svn into the new git repo with access to the individual commits. 最终,我要实现的是将旧svn的补丁分支重新创建到新的git repo中,并可以访问各个提交。 What I need to do is create a branch from the tag (easy) and then replay all commits that are currently in the svn/git-svn world into this patch-branch. 我需要做的是从标签创建一个分支(简单),然后将当前在svn / git-svn世界中的所有提交重放到此补丁分支中。

So far, I created the tag in the current git repo from the original tag, in addition, I have the git-svn repo next to it and added the git-svn repo as a remote. 到目前为止,我是在原始标签的当前git repo中创建标签的,此外,我在其旁边有git-svn repo并将git-svn repo添加为远程标签。 I then created another branch that is checkout from that remote. 然后,我创建了另一个从该远程结帐的分支。 (I got this idea from Easiest way to replay commits on new git repository (我是从最简单的方式来重播新git仓库上的提交的想法

In my naivety, I thought I could then merge the two branches, but this doesn't seem to work. 天真地,我以为可以合并两个分支,但这似乎行不通。 First, git merge doesn't want to merge unrelated histories and if I told it to ignore that, what happens is that all files as a whole are more or less copied over with everything marked as a conflict. 首先,git merge不想合并无关的历史记录,如果我让它忽略这一点,将会发生的情况是,整个文件或多或少都被复制了,而所有文件都标记为冲突。

So, ultimately the question is, can I transport those commits over? 因此,最终的问题是,我可以将这些提交移交给其他人吗? Since we are talking about 100+ commits, I don't want to do this manually. 由于我们正在谈论100多个提交,因此我不想手动执行此操作。

The solution is actually fully described in Easiest way to replay commits on new git repository 实际上,该解决方案已以最简单的方式完整描述, 可以在新的git存储库中重播提交

Basically, add the old repo as a remote. 基本上,将旧仓库添加为远程仓库。 Check it out as a new branch, rebase this branch on the new branch where the commits should go. 将其检出为新分支,将该分支重新建立在应该提交提交的新分支上。 Checkout the new branch and merge it with the rebased one. 签出新分支并将其与重新建立分支的分支合并。

Also thanks to @eftshift0 for hinting in the same direction. 也要感谢@ eftshift0向同一方向提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM