0

I need to recreate some commits from one git repository to another that are seemingly unrelated. The situation is as follows:

Repository 1 is a git-svn repo that contains the commits I want to replay into the other. Contentwise it's a collection of patches that were created in a support branch since we tagged a release.

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

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

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

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.

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.

Christian
  • 1
  • 3
  • Cherry-pick (or even rebase) should work. As long as you have visibility of the two branches involved on a single repo (like... you have access to svn through git-svn and see the other git repo as a remote). – eftshift0 Jul 09 '19 at 14:33
  • So, What I need to do is rebase the 'old' svn commits on top of the patch-branch (which is at its point of creation just the original tag) and then merge this into the patch-branch? – Christian Jul 09 '19 at 14:44
  • Thanks a lot, it actually worked. My problem was I had to actually wrap around my head what rebase does. Thanks, I think I understand it now! – Christian Jul 09 '19 at 15:05

1 Answers1

0

The solution is actually fully described in Easiest way to replay commits on new git repository

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.

0andriy
  • 4,183
  • 1
  • 24
  • 37
Christian
  • 1
  • 3