给定一个包含许多分支的大型 Subversion 存储库,我想开始使用git-svn
通过克隆trunk
首先,然后添加特定分支。我看到至少三种方法可以做到这一点,但是其中任何一种都是“官方的”还是有最好的方法?
假设以下布局:
https://svn-repo.com/svn/company
+--core
| +--trunk
| +--branches
| | +--fastboot
| | +--playground
| +-tags
+--mobile
+--trunk
+--branches
+--tags
因此,仅克隆项目的主干(无分支)修订版 12345core
:
$ git svn clone --username=svnuser -r 12345 -Ttrunk https://svn-repo.com/svn/company/core
这将克隆项目core
进入同名目录并运行git svn rebase
将引入所有更改(修订版 12345 之后)。在此刻.git/config
里面应该有这样的东西:
[svn-remote "svn"]
url = https://svn-repo.com/svn/company
fetch = core/trunk:refs/remotes/trunk
到目前为止,一切都很好。现在,假设我想添加playground
分支。这就是它变得有点模糊的地方。
Option 1:更新现有的遥控器.git/config
通过在那里添加分支:
[svn-remote "svn"]
url = https://svn-repo.com/svn/company
fetch = core/trunk:refs/remotes/trunk
branches = core/branches/{playground}:refs/remotes/branches/*
此时,我能够做到:
-
拉入分支修订版 23456playground
$ git svn fetch -r 23456
-
创建本地分支并切换到该分支
$ git checkout -b playground branches/playground
-
拉取最新更改:
$ git svn rebase
Option 2:添加一个新的遥控器.git/config
(除了现有的):
[svn-remote "playground"]
url = https://svn-repo.com/svn/company
fetch = core/branches/playground:refs/remotes/playground
从这里开始,步骤与以下步骤类似Option 1:
$ git svn fetch playground -r 23456
$ git checkout -b playground remotes/playground
$ git svn rebase
Option 3:我还看到有人在现有的远程中添加了新的获取:
[svn-remote "svn"]
url = https://svn-repo.com/svn/company
fetch = core/trunk:refs/remotes/trunk
fetch = core/branches/playground:refs/remotes/branches/playground
我不完全确定这是否正确或者是否有效。我找不到我在哪里看到的。
目前,我坚持Option 1,但我真的很想知道最合适的方法来做到这一点。