问题描述
我们公司有两个存储库,用于开发一种产品的svn存储库(主干)和用于部署多个产品(团队)的git存储库(主主).我们的团队希望将svn子目录"trunk/web"合并到git子目录"master/product-a/web-dev".
Our company has two repositories, svn repository(trunk) used for development of one product and git repository(master) used for deployment of several products(teams). Our team wants to merge from svn subdirectory "trunk/web" to git subdirectory "master/product-a/web-dev".
这些存储库的源代码不同,树结构也不同,但是我们要合并的两个子目录内部的源代码几乎相同.而且,它们没有任何链接,我们现在需要手动合并. Git存储库由其他团队共享,我们无法从头开始构建它(无法进行可能导致日常开发和部署停止的重大更改).
Those repositories have different source codes with a different tree structure, but two subdirectories we want to merge have almost same source codes inside. Also, they're not linked in any way, and we need to merge manually for now. Git repository is shared by other teams and we cannot build it from scratch(cannot make big changes that might stop daily development&deployment).
是否可以从svn子目录合并到git子目录,通过提交,在指定的修订版中自动(通过一些命令或长程序)进行合并?我们需要将commit by commit与commit注释合并,以便可以通过svn中使用的redmine问题编号跟踪git上的更改.
Is it possible to merge from svn subdirectory to git subdirectory, commit by commit, in specified revision rage automatically(by a few commands or a long program)? We need to merge commit by commit with commit comments, so that we can trace changes on git by redmine issue number used in svn.
非常感谢您的帮助.
推荐答案
我通过以下步骤解决了该问题:
I resolved the issue by the following step:
-
通过SVN为Git创建差异补丁
Create diff patch for Git by SVN
svn diff --git -r 12345 > /tmp/12345-fileName.txt
在本地Git存储库上应用补丁
Apply patch on local Git repository
cd /path/to/local/git/repository & git apply /tmp/12345-fileName.txt
在Git上提交
Commit on Git
git commit
我运行了一个Java程序来生成和执行这些命令,然后逐个修订地重复上述步骤,以合并特定范围的修订,从SVN到Git.
I ran a Java program to generate and execute those commands, and repeated the steps above, revision by revision, to merge specific range of revisions from SVN to Git.
我知道这不是一个好习惯,但是我必须在不对版本控制系统进行较大更改的情况下解决当前存在的问题.谢谢大家的建议.
I understand this is not a good practice, but I had to solve the ongoing problem without a big change in version control systems. Thank you all for your advices.
这篇关于从svn合并到git,通过commit提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!