我阅读了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—标记原点
我在一台windows机器上,通过调用
传输.bathttp://svn.my.address/svn/myrepo/trunk https://git.my.address/orga/myrepo
也许任何人都可以使用它。它创建了一个TMP文件夹,用git签出SVN repo,添加新的来源并推送它……然后再次删除文件夹。
@echo off
SET FROM=%1
SET TO=%2
SET TMP=tmp_%random%
echo from: %FROM%
echo to: %TO%
echo tmp: %TMP%
pause
git svn clone --no-metadata --authors-file=users.txt %FROM% %TMP%
cd %TMP%
git remote add origin %TO%
git push --set-upstream origin master
cd ..
echo delete %TMP% ...
pause
rmdir /s /q %TMP%
您仍然需要users.txt和用户映射,如
User1 = User One <u.1@xxx.com>