mka*_*man 4 svn git git-svn gitlab svn2git
(我发布这个问题的目的是为了自己回答这个问题,因为我在其他地方找不到答案.希望它能帮助遇到同样问题的其他人,下次我试图这样做时会帮助我.)
挑战
我想将SVN存储库转换为本地托管的gitlab GIT存储库并维护历史记录.
安装程序
Gitlab 8.5,Ubuntu 14.04 LTS,颠覆1.8.8
问题
使用git-svn或svn2git从svn转换为git的初始尝试导致以下错误.
错误
svn-remote.svn: remote ref '//example.com:81/svn/myrepository/trunk:refs/remotes/trunk' must start with 'refs/'
我试过的
我在下面的外部参考资料中都遵循了两个指南.
使用外部参考
生成authors.txt文件.这将包含SVN用户和Gitlab用户之间的映射:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
否则,请按照以下格式手动创建它:
oldSVNusername = newGitlabUsername <gitlabRegisteredEmailAddress@example.com>
创建临时目录init SVN repo
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仓库中
git svn fetch
git clone . ../myrepository
cd ../myrepository
在gitlab中设置新的存储库,确保您的用户可以访问它.
添加远程gitlab存储库
git remote add gitlab gitlab.example.com:gitlab-group/myrepository.git
仔细检查您的配置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
现在你应该将所有文件和历史转换为git并在gitlab中显示.
删除前导 / 斜杠对我有用:
这将不起作用:
git svn clone "http://..." --prefix=svn/ --trunk=/trunk --branches=/branches --tags=/tags --authors-file "authors-transform.txt" "C:\Temp\GitRepos"
Run Code Online (Sandbox Code Playgroud)
这有效:
git svn clone "http://..." --prefix=svn/ --trunk=trunk --branches=branches --tags=tags --authors-file "authors-transform.txt" "C:\Temp\GitRepos"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3479 次 |
最近记录: |