简体   繁体   English

在没有共同祖先的情况下如何将提交从一个git repo移动到另一个git repo

[英]How to move commits from one git repo to another when there is no common ancestor

So I searched around for a bit and found a few things that I though should have worked, yet they haven't (it is possible I am doing something wrong) 所以我四处搜寻,发现了一些我本应该工作的东西,但是却没有(可能我做错了)

Here is the story in order 这是顺序的故事

1) We had an SVN repository 1)我们有一个SVN信息库

2) I converted the SVN repo to Git, but didn't use the --stdlayout argument (mistakes were made) at the time so instead of getting a nice history of all the branches and merges it was just had a big branches folder. 2)我将SVN存储库转换为Git,但是当时没有使用--stdlayout参数(犯了错误),因此它没有获得所有分支的良好历史记录并进行合并,而只是拥有一个大分支文件夹。 All of the commits were there, but the branching and merging history did not follow. 所有提交都在那儿,但是分支和合并的历史并没有遵循。 We took the contents of the trunk folder (the most recent code), moved it up to the root of the repo, and deleted everything else. 我们获取了主干文件夹的内容(最新代码),将其移至存储库的根目录,并删除了其他所有内容。 We could go back and look at other stuff if needed, but couldn't see proper branching history. 如果需要,我们可以回头看看其他内容,但是看不到正确的分支历史。

3) We made tons of code changes (and branches) in the new Git repo 3)我们在新的Git存储库中进行了大量的代码更改(和分支)

4) We decided we wanted to be able to annotate a file back to it's beginning which is not something we could do at this point 4)我们决定希望能够在文件开始时对其进行批注,这是我们目前无法做的事情

5) I took the SVN repo and reconverted it to Git and used the --stdlayout command this time so we got a proper history. 5)这次我将SVN存储库转换为Git,并使用--stdlayout命令,以便获得正确的历史记录。

So now the challenge is to take all of the commits that we made since our initial conversion into the new repo. 因此,现在的挑战是要采用自最初转换为新仓库以来的所有提交。 So one repo has junk history before that time and all of our new changes after that time, and the other repo has good history before that time, but nothing since. 因此,一个存储库在此之前具有垃圾记录,而在此之后我们进行了所有新更改,而另一个存储库在此之前具有良好的记录,但此后一直没有。

So far I have fresh cloned the 2nd repo and added the old repo with all the changes as a remote. 到目前为止,我已经新克隆了第二个存储库,并将所有更改作为旧存储库添加为远程库。 I tried to rebase, create and apply patches, perform a gaft, and use git-reset. 我试图重新设定基准,创建和应用补丁,执行替换以及使用git-reset。 I have been unsuccessful in all of my attempts, but I may be doing something incorrectly. 我的所有尝试都没有成功,但是我可能做错了什么。

What is the easiest way to achieve this while still keeping the branching and merging history both before and after the initial move? 在保持初始移动前后的分支和合并历史记录的同时,最简单的方法是什么?

Thank you guys in advance for your help, and sorry for my lack of knowledge. 预先感谢你们的帮助,对我缺乏知识表示抱歉。 This should have never been a problem in the first place. 首先,这本来应该不是问题。

Not sure if this helps, but here is the point in my tree where the original conversion (blue) happened and where it aligns with the new repo (pink). 不确定这是否有帮助,但是这是我的树中发生原始转换(蓝色)并将其与新存储库(粉红色)对齐的点。 I basically want to just change the parent of the first commit after the initial conversion to be the last commit from the second conversion (see pic). 我基本上只想将初始转换后的第一次提交的父级更改为第二次转换之后的最后一次提交(请参见图片)。 Visual Tree 视觉树

您可以从旧存储库创建一个diff / patch文件,并将相同的diff应用于新存储库

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

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