seo 网站结构优化,电脑网页版微信,青岛官网优化推广,集团网站建设案例与《SVN迁移至GitLab#xff0c;并附带历史提交记录》用的 git svn clone不同#xff0c;本文使用svn2git来迁移项目代码。
一、准备工作
安装Git环境#xff0c;配置本地git账户信息#xff1a;
git config --global user.name XXX
git config --global us…与《SVN迁移至GitLab并附带历史提交记录》用的 git svn clone不同本文使用svn2git来迁移项目代码。
一、准备工作
安装Git环境配置本地git账户信息
git config --global user.name XXX
git config --global user.email XXXmail.com可通过命令git config -l 查看结果
安装git-svn运行git svn -h若正常输出帮助信息说明安装没问题。安装ruby运行ruby -h若正常输出帮助信息说明安装没问题。执行下面命令安装svn2git注意下面命令依赖ruby。
gem install svn2git再运行svn2git -h若正常输出帮助信息说明安装没问题。
svn账号与git账号映射新建文件 userinfo.txt左侧是SVN的账号右侧是git账号信息用号连接
svn1git1git1mail.com
svn2git2git2mail.com
svn3gitxgitxmail.com注意 需要将涉及到的同步记录中的用户都做映射否则在同步时可能会报错对于无法对应的人员如离职人员有SVN账号但是没有现在的GIT账号保险起见可以采用无关紧要的账号进行对应或者单独建一个账号也可以例如使用的test账号进行标识的 二、导出SVN项目至本地
创建空文件夹用于存放SVN的代码并将userinfo.txt文件放置在同一层级
│ userinfo.txt
└─ MyProject鼠标右键 选中Git Bash Here 进入git命令行执行
svn2git svnUrl --authors userinfo.txt -v这里的-v会输出执行过程的信息方便debug。此处的 -r 12345:HEAD 表示从svn的12345版本到最新版本的提交记录避免拉取所有数据量过大操作耗时高。svnurl是svn项目地址。如果需要拉取所有记录可去除 -r 12345:HEAD 如果在windows有下面错误
D:\MyProjectsvn2git https:/xxx.com:8443/svn/SVN2GIT/ --authors authors.txt -v
Running command: git svn init --prefixsvn/ --no-metadata --trunktrunk --tagstags --branchesbranches https:/xxx.com:8443/svn/SVN2GIT/
Initialized empty Git repository in D:/MyProject/.git/
Running command: git config --local --get user.name
Running command: git config --local svn.authorsfile authors.txt
Running command: git svn fetch
Running command: git branch -l --no-color
Running command: git branch -r --no-color
Running command: git config --local --get user.name
Running command: git config --local --get user.email
Running command: git checkout -f master
error: pathspec master did not match any file(s) known to git
command failed:
git checkout -f master去安装目录C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\svn2git-2.4.0\lib\svn2git找到migration.rb文件把#{trunk}、 #{tag} 、#{branch}两边的单引号删除再重新执行上面命令。 参考自svn2git - command failed
三、与远程git仓库关联起来
进入项目文件夹
cd MyProject关联远程事先创建好的git项目
git remote add origin gitURL如git remote add origin http://192.168.1.xx:5678/MyProject.git
查看关联情况:
git remote -v如果关联有误可以删除关联
git remote rm origin推送本地项目到git仓库
提交记录之前先拉取远程git项目文件(如README.md)否则直接提交会报错
git pull --rebase origin master拉取成功后推送主分支trunk代码
git push -u origin --all或
git push --all origin推送tags代码
git push -u origin --tagsref: 1.从 SVN 到极狐GitLab的迁移指南 2. https://github.com/nirvdrum/svn2git