0

我正在使用 SubGit 将代码从 SVN 迁移到 GIT。我的一些 SVN 存储库构建为:

SVN-Repo
    + Project1
        + trunk
        + branches
        + tags
    + Project2
        + trunk
        + branches
        + tags

使用 SubGit:

subgit import --svn-url <svn_server>/SVN-Repo/Project1 C:\GitRepos\SVN-Repo\Project1.git --username xxx --password xxx.

在我在本地仓库中克隆之后。

然后:

git clone <Git_server>/_git/GIT-Repo
git push -u origin --all

结果是,在最后的 GIT-Repo 中,我没有一个名为 Project1 的文件夹,就像我在 SVN 中一样。经过调查,我没有找到允许我创建这个 Proejct1 文件夹 GIT 存储库的命令。

你能帮帮我吗?

先感谢您。

4

2 回答 2

1

有3个选项

选项 1.你已经做了什么(最合理的选项)。将 SVN 中的两个项目转换为 2 个独立的 Git 存储库。然后使用 GitLab、Atlassian Bitbucket Server 或任何其他 Git 服务器软件设置对存储库的访问。

选项 2.将整个 SVN 存储库视为单个目录。

subgit configure --svn-url <svn_server>/SVN-Repo --layout directory C:\GitRepos\SVN-Repo\repo.git

subgit install C:\GitRepos\SVN-Repo\repo.git

然后你可以运行

subgit uninstall C:\GitRepos\SVN-Repo\repo.git

如果您不需要连续同步。在这种情况下,Git 存储库将植根于 SVN-Repo。

选项 3。一个 Git 存储库,其中包含来自两个项目的分支。

subgit configure --svn-url <svn_server>/SVN-Repo C:\GitRepos\SVN-Repo\repo.git

然后编辑repo.git/subgit/config设置

trunk = Project1/trunk:refs/heads/project1-master
branches = Project2/trunk:refs/heads/project2-master
branches = Project1/branches/*:refs/heads/project1-*
branches = Project2/branches/*:refs/heads/project2-*
shelves = shelves/*:refs/shelves/*
tags = Project1/tags/*:refs/tags/project1-*
tags = Project2/tags/*:refs/tags/project2-*

然后运行

subgit install C:\GitRepos\SVN-Repo\repo.git

然后你可以运行

subgit uninstall C:\GitRepos\SVN-Repo\repo.git

如果您不需要连续同步。

在这种情况下,您有 1 个 Git 存储库,其分支以您的项目开头project1-project2-对应于您的项目。代替project1-/project2-你也可以使用project1// project2/

因此,根据您的需要,您可以选择这 3 个选项之一,但第一个是最好的。

于 2016-04-14T13:36:49.903 回答
0

对于 SVN 到 git 的一次性转换,我建议使用 svn2git。有许多具有此名称的工具。可能最好的是https://github.com/svn-all-fast-export/svn2git上的 KDE 。要预先分析 SVN 回购历史以建立适当的 svn2git 规则,您可以从此处使用 svneverever:http ://blog.hartwork.org/?p=763 。

我已经使用这些将几个 SVN 存储库转换为 Git,并且做得非常好。

您可以使用prefix那里的规则来获取您想要的子目录。

于 2016-04-14T12:15:05.013 回答