作为Windows用户,我们创建了一个带有文件夹层次结构的svn repo。底部节点包含svn标准布局:
ProjectA/
ApplicationOne/
ModuleX/
trunk/
branches/
tags/
ApplicationTwo/
ModuleY/
trunk/
branches/
tags/
...等无限的广告。 repo现在包含大约100多个带有trunk / branches / tags结构的真实svn项目,但是它们几乎都不在顶层。
我如何配置subgit来处理这个?
答案 0 :(得分:7)
SubGit可以在两种不同的模式下工作:本地镜像模式和远程镜像模式。您可以在下面找到这些模式的一般概述以及针对您的特定情况的一些建议。
本地镜像模式
在这种模式下,Subversion和Git存储库都驻留在同一主机上,因此SubGit可以对SVN和Git端进行本地访问。
下面我提供了基本说明。请在SubGit 'Local Mode' Book中找到详细的文档和常见陷阱。
配置
subgit configure <SVN_REPO>
SubGit version <VERSION> build #<BUILD_NUMBER>
Detecting paths eligible for translation... done.
Subversion to Git mapping has been configured:
/ProjectA/ApplicationOne/ModuleX : <SVN_REPO>/git/ProjectA/ApplicationOne/ModuleX.git
/ProjectA/ApplicationTwo/ModuleY : <SVN_REPO>/git/ProjectA/ApplicationTwo/ModuleY.git
...
CONFIGURATION SUCCESSFUL
...
此命令尝试自动检测存储库布局并在<SVN_REPO>/conf/subgit.conf
生成配置文件。如果像您这样的Subversion存储库可能需要一段时间。
请确保自动生成的配置文件如下所示,必要时进行调整:
...
[git "ProjectA/ApplicationOne/ModuleX"]
translationRoot = /ProjectA/ApplicationOne/ModuleX
repository = git//ProjectA/ApplicationOne/ModuleX.git
pathEncoding = UTF-8
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
shelves = shelves/*:refs/shelves/*
tags = tags/*:refs/tags/*
...
作者映射
在此阶段,您必须创建将现有SVN用户名映射到Git作者的/conf/authors.txt文件。有关详细信息,请参阅documentation。
安装
最后,您必须将Subversion存储库导入Git并通过运行subgit install
命令启用同步:
subgit install repo
SubGit version <VERSION> build #<BUILD_NUMBER>
Subversion to Git mapping has been found:
/ProjectA/ApplicationOne/ModuleX : <SVN_REPO>/git/ProjectA/ApplicationOne/ModuleX.git
/ProjectA/ApplicationTwo/ModuleY : <SVN_REPO>/git/ProjectA/ApplicationTwo/ModuleY.git
...
Processing '/ProjectA/ApplicationOne/ModuleX'
Translating Subversion revisions to Git commits...
Processing '/ProjectA/ApplicationTwo/ModuleY'
Translating Subversion revisions to Git commits...
...
Subversion revisions translated: <REVISIONS_NUMBER>.
Total time: <TIME_SPENT> seconds.
INSTALLATION SUCCESSFUL
Git服务器
当安装结束并且启用Subversion和Git存储库之间的同步时,您可以设置一些Git服务器(或重用现有的Apache HTTP服务器)。请参阅documentation,并在我们的博客中查看有关此主题的几篇帖子:
远程镜像模式
使用此模式时,必须仅将SubGit安装到Git存储库中,并使此存储库与托管在其他计算机上的远程Subversion服务器保持同步。
您可以在下面找到一些基本说明。有关详细信息,请参阅SubGit 'Remote Mode' Book。
配置
在远程镜像模式下,SubGit不会尝试自动检测存储库布局,因此您必须为Subversion存储库中的每个模块运行subgit configure --svn-url <SVN_URL>
命令:
subgit configure --svn-url <SVN_ROOT_URL>/ProjectA/ApplicationOne/ModuleX <GIT_ROOT_DIR>/ProjectA/ApplicationOne/ModuleX.git
SubGit version <VERSION> build #<BUILD_NUMBER>
Configuring writable Git mirror of remote Subversion repository:
Subversion repository URL : <SVN_ROOT_URL>/ProjectA/ApplicationOne/ModuleX
Git repository location : <GIT_ROOT_DIR>/ProjectA/ApplicationOne/ModuleX.git
CONFIGURATION SUCCESSFUL
...
结果,SubGit为每个Git存储库生成配置文件<GIT_REPO>/subgit/config
。对于您的情况,此配置文件应如下所示:
...
[svn]
url = <SVN_ROOT_URL>/ProjectA/ApplicationOne/ModuleX
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
fetchInterval = 60
connectTimeout = 30
readTimeout = 60
keepGitCommitTime = false
auth = default
[auth "default"]
passwords = subgit/passwd
useDefaultSubversionConfigurationDirectory = false
subversionConfigurationDirectory = <SVN_CONFIG_DIR>
...
作者映射
在此阶段,您必须创建/subgit/authors.txt文件,将现有SVN用户名映射到Git作者。有关详细信息,请参阅documentation。
SVN凭据
如果您不使用 file:// 协议,则必须提供必要的凭据,因此SubGit能够对Subversion服务器进行身份验证。有关详细信息,请阅读SubGit Book中的corresponding chapter。
我们还建议在Subversion端启用pre-revprop-change
挂钩,这样可以更轻松地进一步安装和维护,请参阅SubGit Book。
安装
最后,您必须将Subversion存储库导入Git并通过运行subgit install
命令启用同步:
subgit install git
SubGit version <VERSION> build #<BUILD_NUMBER>
Translating Subversion revisions to Git commits...
Subversion revisions translated: <REVISIONS_NUMBER>.
Total time: <TIME_SPENT> seconds.
INSTALLATION SUCCESSFUL
此命令还会启动后台进程,轮询SVN服务器并在其出现时获取新修订。基本上,这意味着SubGit为每个Git存储库使用专用进程。有时,避免运行此类进程并使用某些作业调度程序是有意义的。
Git服务器
我上面提供的那些链接也与远程模式相关。
但是,如果你打算使用Atlassian Stash进行Git托管,你可以使用基于SubGit引擎的SVN Mirror Plugin,并提供一些关于UI和维护的更好体验。
根据我们的经验,我们有以下指南:
如果有许多独立的Subversion存储库,最好在本地镜像模式下使用SubGit,因为它不需要SVN轮询并为此维护其他进程。
如果有一个包含许多模块的巨型Subversion存储库,最好将远程镜像模式与 file:// 协议一起使用,并稍微调整基本设置。
在您的情况下运行100多个后台进程绝对没有意义,相反,我们建议安装额外的提交后SVN挂钩,检查给定修订版修改了哪些特定模块,然后触发相应Git存储库的同步。
如果您有任何其他问题,请随时在Stack Overflow上询问我们our issue tracker或通过电子邮件与我们联系:support@subgit.com。