简体   繁体   English

如何同步SVN和Git存储库?

[英]How to sync SVN and Git repositories?

My client is using SVN and my company is using Git (central bare Git repo). 我的客户使用的是SVN,我的公司使用的是Git(中央裸Git仓库)。 So I have the task to sync both servers. 因此,我的任务是同步两个服务器。 I can't use SubGit , because I can't do any modification on either server. 我不能使用SubGit,因为我不能在任何一台服务器上进行任何修改。

I successfully used git-svn to download the SVN to my local Git repo (using TortoiseGit). 我成功使用git-svn将SVN下载到我的本地Git存储库(使用TortoiseGit)。 But I can't figure out how to set up a remote upstream to the central Git Repository (using Egit in Eclipse). 但是我不知道如何在中央Git信息库的上游建立一个远程上游(在Eclipse中使用Egit)。

Is it possible to set up a remote branch, so I can check in the SVN stuff from my local Git into the central Git repo? 是否可以设置一个远程分支,以便我可以将SVN内容从本地Git检入到中央Git存储库中? How? 怎么样?

thanks. 谢谢。

If I understand correctly, you can't update hooks in SVN and Git repositories. 如果我理解正确,您将无法更新SVN和Git存储库中的挂钩。 That complicates the task a lot, because you can't reject pushes Git if someone is committing to SVN at the same moment and vice versa. 这使任务变得非常复杂,因为如果有人同时提交SVN,则不能拒绝push Git,反之亦然。

I think, that git-svn is not a solution because on sending commits to SVN ("git svn dcommit") it changes Git commit SHA-1 to add git-svn-id: signature. 我认为git-svn不是解决方案,因为在将提交发送到SVN时(“ git svn dcommit”),它会更改Git提交SHA-1以添加git-svn-id:签名。 As result when one pushes commit C to your Git repository, you fetch that commit to your git-svn repsository, run "git svn dcommit", it translates it to SVN and adds git-svn-id: signature to commit message thus changing commit SHA-1, so you'll get another commit C' in git-svn repository. 结果,当有人将提交C推送到您的Git存储库时,您将提交提交到git-svn代表,运行“ git svn dcommit”,将其转换为SVN并添加git-svn-id:签名以提交消息,从而更改提交SHA-1,因此您将在git-svn存储库中获得另一个提交C'。 After that C' should be sent back to the Git repository, and after that the user that pushed C should download C' and replace C with C' in his working copy. 之后,应将C'发送回Git存储库,然后,按下C的用户应下载C',并在其工作副本中将C替换为C'。 So you won't have easy and transparent synchronization. 因此,您将不会获得简单透明的同步。

With SubGit you can reduce your problem to synchronization of 2 Git repositories by creation of an "intermediate" Git repository with SubGit installed into it. 使用SubGit,您可以通过创建一个安装有SubGit的“中间” Git存储库,将问题减少到2个Git存储库的同步。 Synchronization of 2 Git repositories is a simpler task (and there's a lot of solutions on the internet) but it's still isn't a piece of cake, because 2 different users can push into both repositories simultaneously (and you can't discard one of the push, because you can't create hooks in the repositories). 同步2个Git存储库是一个比较简单的任务(互联网上有很多解决方案),但这并不是小菜一碟,因为2个不同的用户可以同时推送到两个存储库中(并且您不能丢弃其中一个推送,因为您无法在存储库中创建钩子)。 If these changes are conflicting, you can resolve that only manually , and I'm afraid this is the best you can do: create a repository with 2 remote and using a script constantly fetch changes from one of them and push the changes to another one and vice versa (and notify the administrator and stop synchronization on simultaneous conflicting changes). 如果这些更改有冲突,则只能手动解决该问题,恐怕这是您可以做到的最好:创建一个具有2个remote的存储库,并使用脚本不断地从其中的一个获取更改并将更改推送到另一个反之亦然(并通知管理员并在同步发生冲突的更改时停止同步)。

Disclaimer: I can be biased because I'm one of SubGit developers. 免责声明:因为我是SubGit开发人员之一,所以我可能会有偏见。

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

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