我想将 svn 项目复制到 git with history

I'd like to copy svn project to git with history

我想将 svn 项目复制到 linux 环境中的 git 项目。目前我在 svn repo 中有我的项目,带有分支、标签和主干文件夹结构。我需要将所有内容复制到 git 存储库,包括历史记录。我考虑过使用 svn2git,但对我需要遵循的步骤不太了解。

svn2git 是一个很棒的工具。我正在用它来迁移一个大项目。您需要为每个 branch/tags 定义规则。外卡是你的朋友。

trunk/A/B
branches/Foo/A/B
branches/Bar/A/B
tags/Baz/A/B
tags/Foobar/A/B

这里有一些示例规则。注意:规则按顺序 运行。

match /trunk/
  branch master
end match

match /branches/([^/]+)/
  branch 
end match 

match /tags/([^/]+)/
  branch refs/tags/
  annotated true
end match

这将产生以下分支:master、Foo 和 Bar 以及标签 Baz 和 Foobar。

我花了一段时间才弄清楚的是,如果您需要更深入地研究您需要使用递归函数的路径。例如,如果提交将所有分支复制到标记中,则路径将只是 /branches/。您需要规则才能进入目录。

match /branches/$
  action recurse
end match

在编写规则之前使用的另一个很棒的工具是 svneverever。它将帮助您编写规则。

https://blog.hartwork.org/posts/before-svn2git-you-want-to-run-svneverever/