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博客

相关推荐
dalianwawatou7 小时前
GitLab 代码基础操作清单
大数据·elasticsearch·gitlab
默默coding的程序猿2 天前
3.git的分支携带问题是什么?怎么解决?
java·git·python·svn·gitee·github·intellij-idea
爱宇阳3 天前
从零开始部署 GitLab CE 18.4.2:Docker Compose 新手教程
docker·容器·gitlab
Narutolxy4 天前
从混合部署到高可用:在内网环境下搭建 GitLab-Jenkins-OpenResty的完整实战复盘20251014
gitlab·jenkins·openresty
字节逆旅4 天前
Git提交后追加修改操作指南
gitlab
爱宇阳4 天前
GitLab Docker Compose 迁移教程
docker·容器·gitlab
Blue啊4 天前
code Merge(qcc)
git·gitlab
友莘居士4 天前
极速迁移:GitLab项目无缝转移实战手册
gitlab·代码迁移·git命令
谢栋_4 天前
基于 GitLab CI/CD 与 Google Gemini 的 AI Code Review 自动化方案
人工智能·ci/cd·gitlab
摇滚侠5 天前
Eclipse MyEclipse MyEclipseCI 安装SVN插件及使用说明
svn·eclipse·myeclipse