简体   繁体   中英

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

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. 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

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

5) I took the SVN repo and reconverted it to Git and used the --stdlayout command this time so we got a proper history.

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. 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应用于新存储库

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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