我阅读了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
我不希望它这么简单,也不希望它是一个命令。但我确实希望它不要试图解释任何事情——只是说在这个例子中应该采取什么步骤。
从Subversion到Git(或同时使用两者)的平滑迁移有一个新的解决方案:SubGit。
我自己在做这个项目。我们在我们的存储库中使用SubGit——我的一些队友使用Git和一些Subversion,到目前为止它工作得很好。
要使用SubGit从Subversion迁移到Git,您需要运行:
$ subgit install svn_repos
...
TRANSLATION SUCCESSFUL
之后,您将获得svn_repos/.Git中的Git存储库,并可以克隆它,或者继续使用Subversion和这个新的Git库:SubGit将确保两者始终保持同步。
如果Subversion存储库包含多个项目,那么将在svn_repo/Git目录中创建多个Git存储库。要在运行翻译之前自定义翻译,请执行以下操作:
$ subgit configure svn_repos
$ edit svn_repos/conf/subgit.conf (change mapping, add authors mapping, etc)
$ subgit install svn_repos
使用SubGit,您可以迁移到纯Git(而不是Git-svn)并开始使用它,同时只要您需要它,就可以保留Subversion(例如,对于您已经配置的构建工具)。
希望这有帮助!
我只是想把我的贡献加入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 .
为此,我使用了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—标记原点
我已经发布了一个将svn转换为git的分步指南(这里),包括将svn标记转换成git标记,将svn分支转换成git分支。
简短版本:
1) 从特定版本号克隆svn。(修订号必须是要移植的最旧版本)
git svn clone --username=yourSvnUsername -T trunk_subdir -t tags_subdir -b branches_subdir -r aRevisionNumber svn_url gitreponame
2) 获取svn数据。这一步是最耗时的一步。
cd gitreponame
git svn fetch
重复git-svn获取,直到无错误完成
3) 更新主分支
git svn rebase
4) 通过复制引用从svn分支创建本地分支
cp .git/refs/remotes/origin/* .git/refs/heads/
5) 将svn标记转换为git标记
git for-each-ref refs/remotes/origin/tags | sed 's#^.*\([[:xdigit:]]\{40\}\).*refs/remotes/origin/tags/\(.*\)$#\2 \1#g' | while read p; do git tag -m "tag from svn" $p; done
6) 将存储库放在更好的地方,如github
git remotes add newrepo git@github.com:aUser/aProjectName.git
git push newrepo refs/heads/*
git push --tags newrepo
如果你想了解更多细节,请阅读我的帖子或询问我。