我阅读了Git手册、常见问题解答、Git-SVN速成课程等,他们都解释了这一点和那一点,但你找不到像这样的简单说明:
SVN存储库位于:svn://myserver/path/to/svn/repos
Git存储库位于:git://myserver/path/to/git/repos
git-do-the-magic-svn-import-with-history \
svn://myserver/path/to/svn/repos \
git://myserver/path/to/git/repos
我不希望它这么简单,也不希望它是一个命令。但我确实希望它不要试图解释任何事情——只是说在这个例子中应该采取什么步骤。
为此,我使用了svn2git库,过程如下:
sudo apt-get安装git-core git-svn-rubysudo gem安装svn2gitsvn log--quiet|grep-E“r[0-9]+\|.+\|”|cut-d'|'-f2|sed's///g'|sort|uniq>authors.txt(此命令用于映射作者)
以上步骤应该在要从svn转换为git的文件夹中执行。
在authors.txt中每行添加一个映射,如下所示
anand = Anand Tripathi <email_id>
trip = Tripathi Anand <email_id>
为新的git存储库创建一个文件夹,并执行以下命令,路径为authors.txt
svn2git <svn_repo_path> --nobranches --notags --notrunk --no-minimize-url --username <user_name> --verbose --authors <author.txt_path>
If no trunk and no tag and branch is present then have to execute the above command else if root is trunk then mention rootistrunk or trunk is present then --trunk <trunk_name>
git远程添加原点git push—所有原点git push—标记原点
我只是想把我的贡献加入Git社区。我编写了一个简单的bash脚本,可以自动完成整个导入。与其他迁移工具不同,该工具依赖于原生git而不是jGit。该工具还支持具有较大修订历史和/或较大Blob的存储库。可通过github获得:
https://github.com/onepremise/SGMS
此脚本将以以下格式转换存储在SVN中的项目:
/trunk
/Project1
/Project2
/branches
/Project1
/Project2
/tags
/Project1
/Project2
该方案也很受欢迎和支持:
/Project1
/trunk
/branches
/tags
/Project2
/trunk
/branches
/tags
每个项目将按项目名称同步:
Ex: ./migration https://svnurl.com/basepath project1
如果要转换完整回购,请使用以下语法:
Ex: ./migration https://svnurl.com/basepath .
这里有一个简单的shell脚本,它没有依赖关系,可以将一个或多个SVN存储库转换为git并将其推送到GitHub。
https://gist.github.com/NathanSweet/7327535
在大约30行脚本中:使用git SVN克隆,从SVN::ignore财产创建一个.gitignore文件,推入一个裸git存储库,重命名SVN主干为master,将SVN标记转换为git标记,并将其推送到GitHub,同时保留标记。
我经历了很多痛苦才将十几个SVN存储库从Google Code迁移到GitHub。我使用Windows并没有帮助。Ruby在我的旧Debian盒子上摔坏了,让它在Windows上运行简直是个笑话。其他解决方案无法使用Cygwin路径。即使我得到了一些有用的东西,我也不知道如何让标签显示在GitHub上(秘诀是——关注标签)。
最后,我拼凑了两个简短而简单的脚本,上面链接了起来,效果很好。解决方案不需要比这更复杂!