SVN单个项目迁移到Gitlab,保留历史提交记录

1.版本说明

svn --version:版本1.14.1

git --version:版本2.43.0.windows.1

git svn --version:执行不报错,显示版本git-svn version 2.43.0.windows.1 (svn 1.14.2)

2.提取用户的列表

提取所有SVN用户的列表到当前路径下的userInfo.txt文件

git 复制代码
# 可以修改指定的邮箱后缀email.com
svn log http://svn的仓库地址/分支名 -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2"="$2" <"$2"@email.com>"}' | sort -u > ./userInfo.txt

3.使用 git-svn 克隆 SVN 存储库

在userInfo.txt文件所在的路径下执行命令

git 复制代码
git svn clone http://svn的仓库地址/分支名 --no-metadata --no-minimize-url --authors-file=userInfo.txt demo

--no-metadata:不拉取SVN metadata附加信息

--no-minimize-url:克隆时只会拉取你要求的分支项目,不会自动拉取上级内容。不添加此参数会导致不拉取【http://svn的仓库地址/分支名】而拉取【http://svn的仓库地址】

--authors-file=userInfo.txt:根据提供的userinfo.txt文件,将提交的作者名称映射到对应的用户邮箱地址。

demo:本地存放svn指定路径的内容的文件夹

4.push到GitLab仓库

现状

git 复制代码
# 本地master分支和远程git-svn分支
$ git branch -a                                                                       
* master
  remotes/git-svn

# 没有任何输出,没有关联的远程git仓库
git remote -v

添加远程仓库并push

git 复制代码
git remote add origin https://你的gitlab_project_path
git remote -v
git push -u origin master

5.参考

从 Subversion (SVN) 迁移到 Git - Azure Repos | Microsoft Learn

SVN单个项目迁移到Gitlab_svn代码迁移到gitlab-CSDN博客

相关推荐
puamac2 小时前
GitLab CI/CD 指南
gitlab
Rain5092 小时前
GitLab-Runner + AI 代码审查服务 + 远程大模型 全套部署运维实战
linux·运维·人工智能·python·ci/cd·gitlab·ai编程
puamac1 天前
gitLab CI/CD 执行流程说明
ci/cd·gitlab
维度跃迁笔记1 天前
2核4G轻量服务器部署GitLab实战:配置调优与CI/CD拆分方案
服务器·ci/cd·gitlab
Byron Loong2 天前
GitLab 全部权限角色详解
gitlab
Cat_Rocky2 天前
Gitlab安装与配置
linux·运维·gitlab
D4c-lovetrain2 天前
CentOS9 GitLab 完整配置全流程
gitlab
puamac2 天前
GitLab CI/CD 故障排查手册
ci/cd·gitlab
Aubrey-J3 天前
老版本Gitlab SSL证书自动续期错误KeyError: key not found: “token“解决
网络协议·gitlab·ssl
java_logo4 天前
Docker 部署 GitLab CE 完整版教程
docker·容器·gitlab·gitlab docker部署·gitlab部署文档·gitlab部署·gitlab部署教程