将svn分支合并到新的git分支

3
我们正在从svn代码库迁移到git代码库。
尽管svn主干已经迁移,但是分支却没有(svn服务器由另一个团队维护)。
所以我只有一份本地的svn分支副本,它比当前的git仓库要旧近六个月。
如果你想问为什么是六个月,那是因为这是一个非常大的功能,开发花了两个月时间,而剩下四个月被浪费在因为某些阻碍部分而无法发布功能。
那么,我该如何将本地分支上这些六个月前的更改合并到git分支中呢?
1个回答

3
你可以
  • git-svn that SVN repo into a git repo
  • add that new git repo as a remote of your existing git repo and fetch it

    cd /path/to/existing/repo
    git remote add gitsvn /path/to/gitsvn/repo
    git fetch gitsvn
    
  • create a new branch in your current Git repo at a point you estimate that 6 month effort might have started

  • cherry-pick the fetched commit onto that new branch
  • finally, merge that new Git branch in your master branch

好的,我会尝试这个。但是有代码丢失的风险吗? - adi rohan
1
@adirohan 不,代码会在那里:只需要仔细地合并以正确地整合两个历史记录。 - VonC
将新的 Git 仓库添加为现有 Git 仓库的远程仓库。我是 Git 新手,我该怎么做? - adi rohan
好的,我已经到达了 Cherry-pick 点。我使用 SourceTree;在那里我没有看到任何名为 gitsvn 的远程或本地分支。我该如何进行 Cherry-pick? - adi rohan
@adirohan gitsvn只是一个示例,作为您的远程名称(在git remote add gitsvn /path/to/your/git/repo/imported/from/svn中)。首先检查您当前存储库中是否有两个远程(在命令行中:git remote -v),然后返回到您的GUI(这里是SourceTree)并检查您自动刷新这些元数据:请参见https://confluence.atlassian.com/sourcetreekb/refreshing-repository-according-to-file-changes-and-remote-changes-on-sourcetree-785323792.html。 - VonC
显示剩余5条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接