使用带有 svn-git 的 TortoiseGit 克隆 SVN 存储库的特定分支
Using TortoiseGit with svn-git to clone specific branches of SVN repository
我有一个具有以下架构的 SVN 项目(空 trunk
和 tags
)
https://svn-repo.com/svn/company
+--my_project
| +--trunk (empty)
| +--branches
| | +--my_branch
| | +--my_branch2
| | +--temp_branch1
| | +--temp_branch2
| | +--temp_branch3
| +-tags (empty)
我想使用 TortoiseGit 将此存储库克隆到具有分支 my_branch
和 my_branch2
的 git 存储库中,并能够将更改提交回 SVN .
我已经能够通过不选中与主干、标签、分支相关的任何框并将 URL 放入分支(例如 https://svn-repo.com/svn/company/my_project/branches/my_branch
)并指定第一个 SVN 来克隆单个分支分支的修订。
我尝试将 URL https://svn-repo.com/svn/company/my_project
并选中所有框,但每次都失败了。
问题 1: 如何通过 TortoiseGit 将 SVN 仓库及其所有分支克隆到 Git?
问题2:如何(如果存在)只保留Git库中的某些分支(即删除所有分支temp_branchN
)?
我发现了一些 if using git-svn CLI(像这样 related topic),但与 TortoiseGit.
无关
非常感谢
- 你不能在 pure TortoiseGit
中(以好的方式)做到这一点
- 您必须手动编辑
$GIT_DIR/config
文件中的 [svn-remote]
部分
Git-SVN doc 提及 Subversion 存储库的一些罕见情况并提出可能的解决方案:枚举所有需要(并且只需要)的分支
Since some SVN repositories are oddly configured with multiple projects glob expansions such those listed below are allowed:
[svn-remote "project-a"]
...
branches = branches/*/project-a:refs/remotes/project-a/branches/*
branches = branches/release_*:refs/remotes/project-a/branches/release_*
branches = branches/re*se:refs/remotes/project-a/branches/*
...
问题 1 TortoiseGit + 配置文件补丁的混合(c.f. 下面)
问题2根据Lazy Barger的提示,我想出了以下流程
- 只有一个 select 树干的 TortoiseGit 克隆(修订版 12345 对应于树干的创建)
.git/config
手动编辑文件以添加所需的分支
svn-remote
部分增加以下内容
[svn-remote "svn"]
url = https://myserver:8443/svn/WorkRoot
fetch = my_project/trunk:refs/remotes/origin/trunk
branches = my_project/branches/my_branch*:refs/remotes/branches/*
- TortoiseGit
SVN fetch
拔出分支
最后一个命令可能需要一段时间,因为它从修订版 1 开始搜索。
- 执行TortoiseGit
Switch/Checkout
更改分支
注意:要执行等同于svn update
的命令,我使用Git SVN Rebase
和select对应于远程分支的正确上游(而不是主干默认情况下 selected)。
希望对您有所帮助
我有一个具有以下架构的 SVN 项目(空 trunk
和 tags
)
https://svn-repo.com/svn/company
+--my_project
| +--trunk (empty)
| +--branches
| | +--my_branch
| | +--my_branch2
| | +--temp_branch1
| | +--temp_branch2
| | +--temp_branch3
| +-tags (empty)
我想使用 TortoiseGit 将此存储库克隆到具有分支 my_branch
和 my_branch2
的 git 存储库中,并能够将更改提交回 SVN .
我已经能够通过不选中与主干、标签、分支相关的任何框并将 URL 放入分支(例如 https://svn-repo.com/svn/company/my_project/branches/my_branch
)并指定第一个 SVN 来克隆单个分支分支的修订。
我尝试将 URL https://svn-repo.com/svn/company/my_project
并选中所有框,但每次都失败了。
问题 1: 如何通过 TortoiseGit 将 SVN 仓库及其所有分支克隆到 Git?
问题2:如何(如果存在)只保留Git库中的某些分支(即删除所有分支temp_branchN
)?
我发现了一些 if using git-svn CLI(像这样 related topic),但与 TortoiseGit.
无关非常感谢
- 你不能在 pure TortoiseGit 中(以好的方式)做到这一点
- 您必须手动编辑
$GIT_DIR/config
文件中的[svn-remote]
部分
Git-SVN doc 提及 Subversion 存储库的一些罕见情况并提出可能的解决方案:枚举所有需要(并且只需要)的分支
Since some SVN repositories are oddly configured with multiple projects glob expansions such those listed below are allowed:
[svn-remote "project-a"] ... branches = branches/*/project-a:refs/remotes/project-a/branches/* branches = branches/release_*:refs/remotes/project-a/branches/release_* branches = branches/re*se:refs/remotes/project-a/branches/* ...
问题 1 TortoiseGit + 配置文件补丁的混合(c.f. 下面)
问题2根据Lazy Barger的提示,我想出了以下流程
- 只有一个 select 树干的 TortoiseGit 克隆(修订版 12345 对应于树干的创建)
.git/config
手动编辑文件以添加所需的分支
svn-remote
部分增加以下内容
[svn-remote "svn"]
url = https://myserver:8443/svn/WorkRoot
fetch = my_project/trunk:refs/remotes/origin/trunk
branches = my_project/branches/my_branch*:refs/remotes/branches/*
- TortoiseGit
SVN fetch
拔出分支
最后一个命令可能需要一段时间,因为它从修订版 1 开始搜索。
- 执行TortoiseGit
Switch/Checkout
更改分支
注意:要执行等同于svn update
的命令,我使用Git SVN Rebase
和select对应于远程分支的正确上游(而不是主干默认情况下 selected)。
希望对您有所帮助