-
生成一个authors.txt文件。这将包含您的SVN用户和Gitlab用户之间的映射: 可以跳过
- 从现有的svn存储库中:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
-
否则,请按照以下格式手动创建它:
oldSVNusername = newGitlabUsername <gitlabRegisteredEmailAddress@example.com>
- 从现有的svn存储库中:
-
创建一个临时目录初始化SVN存储库
mkdir temp
cd temp
git svn init --no-metadata http://username:password@example.com:81/svn/myrepository
-
配置git
git config svn.authorsfile ~/authors.txt 可以跳过
git config --global user.name myusername
git config --global user.email myusername@example.com
-
抓取文件并将其克隆到新的git repo中
git svn fetch
git clone . ../myrepository
cd ../myrepository
-
在gitlab中设置新的存储库,确保您的用户可以访问它。
-
添加一个远程gitlab存储库
git remote add gitlab gitlab.example.com:gitlab-group/myrepository.git
- 也可以使用gitlib提示信息操作
-
仔细检查您的配置
myrepository/.git/config
(尤其是URL行)[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = /root/temp/. fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = gitlab merge = refs/heads/master [remote "gitlab"] url = http://gitlab.example.com/gitlab-group/myrepository.git fetch = +refs/heads/*:refs/remotes/gitlab/* [user] name = myusername
-
将其全部推向上游
git push --set-upstream gitlab master
搬运from:https://stackoverflow.com/questions/35900710/svn-to-git-conversion-correct-remote-ref-must-start-with-refs-error