没有前缀的 svn 到 git 迁移是否安全?

Is one off svn to git migration without prefix safe?

我在 subversion 中有许多存储库要迁移到 git。 迁移完成后,svn 存储库将被标记为只读并且永远不会再次提交。 在我处理的具体案例中,有两个活动分支,我们称它们为 BranchABranchB。 迁移完成后,我希望它们看起来像 "regular" git 没有前缀的分支。

目前我正在使用命令:

 git svn clone --prefix=svn/ --stdlayout http://repos-url/ <git-name>

在这种情况下,我的分支最终被称为 svn/BranchAsvn/BranchB

但我更愿意使用

 git svn clone --prefix="" --stdlayout http://repos-url/ <git-name>

并让它们在 git 中被称为 BranchABranchB

但是,the docs 警告不要使用这种说法

Setting a prefix (with a trailing slash) is strongly encouraged in any case...

但我不确定我明白为什么。它还说 SVN url 将作为 "remote" 添加,但这并不是我真正想要的。

我担心使用 --prefix="" 之后我会 运行 遇到一些麻烦,因为我不太理解这个警告。

所以我想我的问题是:

你完全可以不使用 --prefix。来自文档...

--prefix=<prefix>

This allows one to specify a prefix which is prepended to the names of remotes if trunk/branches/tags are specified. The prefix does not automatically include a trailing slash, so be sure you include one in the argument if that is what you want.

如果您不想在分支名称前添加前缀,请不要使用 --prefix。这在镜像 SVN 存储库以保持 SVN 分支与 Git 分支分离时非常有用。如果您要迁移,则不需要。

尾部的斜杠注释只是明确表示,如果您说 --prefix=foo,您将得到 fooBranchAfooBranchB。 Git 您的分支名称中是否包含斜杠并不重要。

It also says that the SVN url will be added as a "remote", but that's not really what I want.

这个也是镜像用的,迁移的时候用处不大。

您稍后可以使用 git remote rm 将其删除。或者你可以忽略它。遥控器附加到磁盘上的物理 .git 目录,它们不共享。此遥控器不会被推送到 Git 服务器。克隆存储库的任何人都不会拥有此 svn 远程。

因此,您可以在迁移后通过简单地克隆已迁移的存储库来获得 "clean" 存储库。您还可以克隆目录。

git clone path/to/migrated/repo path/to/clean/repo

Bitbucket has a nice guide on migrating from SVN to Git.


与在 SVN 中 "branches" 是相当笨重的东西不同,Git "branches" 只是实际分支上的标签。与 SVN 不同,SVN 的历史就像一堆煎饼,您只能添加到顶部,Git 历史是 graph 的节点和连接,可以更改。

您不必担心在迁移过程中是否恰到好处,您可以在之后进行一些微调。例如,您可以在迁移后安全地更改 Git 中的分支名称。您可以删除 SVN 遥控器。