git - 我想将 svn 项目复制到带有历史记录的 git
问题描述
我想将 svn 项目复制到 linux 环境下的 git 项目。目前我在 svn repo 中有我的项目,其中包含分支、标签和主干文件夹结构。我需要将所有内容复制到 git repo,包括历史记录。我想过使用 svn2git,但对我需要遵循的步骤没有一个好主意。
解决方案
svn2git 是一个很棒的工具。我正在使用它来迁移一个大型项目。您需要为每个分支/标签定义规则。外卡是你的朋友。
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 \1
end match
match /tags/([^/]+)/
branch refs/tags/\1
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/
推荐阅读
- winapi - 使用 MSI 转换更改从 DLL 加载的 MSI 属性的值
- php - 在 Laravel 中计算数据
- mysql - 如何修复“1054 - 子句上的未知列”
- kotlin - 派生类属性未在 kotlin 中序列化
- angular - PrimeNG Angular2 组件有 DynamicDialogRef 和没有 DynamicDialogRef 的实现问题
- java - itextpdf 表格列数
- reactjs - 我的 onclick 函数与提交处理程序重叠
- vue.js - 在 Vue 项目之间共享资产和组件
- process - 操作系统中的PCB
- mysql - 如果在某些条件下 SQL 中没有值,则计数显示为零?