将代码与两个 subversion 存储库同步 [英] Synchronizing code with two subversion repositories

查看:24
本文介绍了将代码与两个 subversion 存储库同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先介绍一下背景:

  • 我使用的是远程 SVN 存储库中的基本"代码,不受我的控制.代码没有标记(还),所以我总是需要跟上后备箱.

  • I am using "base" code from a remote SVN repository, not under my control. The code is not tagged (yet), so I always need to keep up with the trunk.

出于多种原因(最重要的是我们对代码的本地扩展具有利基"性质,旨在解决使用代码的项目的特定问题)我可以不要使用远程存储库对我在本地所做的任何修改进行版本控制.

For a number of reasons (the most important being that our local extensions to the code are of a "niche" nature, and intended to solve a specific problem with the project in which the code is used) I can't use the remote repository to do version control of any modifications I make locally.

我有一个本地 SVN 存储库,我目前正在其中进行本地"版本控制.

I have a local SVN repository in which I am currently doing the "local" versioning.

我面临的问题:我不知道是否有一种让代码同时与两个存储库同步的好方法.也就是说,我想保留远程"版本信息(以便我可以在将来的更改中合并),但我也想同时拥有本地"版本信息(即,在同一目录结构中).

The problem I'm faced with: I can't figure out if there's a good way to have the code simultaneously synchronized with both repositories. That is, I would like to keep the "remote" version information (so that I can merge in future changes), but I would also like to have "local" version information at the same time (i.e., within the same directory structure).

目前我使用两个不同的目录来执行此操作,它们都包含相同的代码,但每个都包含不同的版本信息.显然这是相当大的开销,尤其是两个目录中的代码需要独立同步.

At the moment I am doing this using two different directories, both containing identical code, but each containing different versioning information. Obviously this is quite a bit of overhead, especially since the code in the two directories needs to be synchronized independently.

有没有办法在颠覆中做到这一点?或者您对解决此问题的替代方法有什么建议?

Is there a way to do this in subversion? Or do you have suggestions about alternative ways of approaching this?

推荐答案

我使用 git svn 做到了这一点,我的开发是在 git 存储库中完成的.远程开发是在subversion中完成的.我制作了一个 subversion 存储库的 git svn 克隆,我将其推送到一个真正的 git 存储库.一个 cronjob 不时运行git svn rebase && git push"来创建一个 subversion 仓库的 git 镜像.

I did this using git svn, with my development done in a git repository. The remote development is done in subversion. I made a git svn clone of the subversion repository, which I push to a real git repository. A cronjob runs "git svn rebase && git push" every now and again to create a git mirror of the subversion repo.

为了合并 subversion 更改,我在本地 git 副本中有 2 个遥控器——本地开发"源和来自 subversion 镜像"源.每当我觉得需要时,我可以将来自 subversion 镜像的更改合并到我们的开发树中.本地更改不受影响,他们分开住,不会弄乱svn镜像.

In order to merge the subversion changes, I have 2 remotes in my local git copy - the "local development" origin and the "from subversion mirror" origin. Whenever I feel the need, I can merge changes from the subversion mirror into our development tree. Local changes are not affected, they live apart and don't mess up the svn mirror.

我使用了 gitosis 设置和管理 git 存储库.步骤应该是这样的(根据记忆,可能是错误的):

I used gitosis to set up and administer the git repositories. The steps would be something like this (from memory, may be wrong):

# set up the mirror
git svn clone -s $SVN
git remote add origin git@$MACHINE:svnmirror.git
git push
# + cron job to do git svn rebase && git push every N hours/minutes

# set up the local working copy for development
git clone git://$MACHINE/svnmirror.git
# that's an anonymous, read only clone 
# no push to the svn mirror for developers - only cronjob user can push there
git remote add newproject git@$MACHINE:myproject.git
git push newproject
# now do the real deal
git clone git://$MACHINE/myproject.git
# hack hack hack
git push # origin master not needed
git remote add svnmirror git://$MACHINE/svnmirror.git
git merge svnmirror/master
git push

这篇关于将代码与两个 subversion 存储库同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆