我阅读了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
我不希望它这么简单,也不希望它是一个命令。但我确实希望它不要试图解释任何事情——只是说在这个例子中应该采取什么步骤。
我只是想把我的贡献加入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 .
我使用以下脚本读取了一个包含所有SVN存储库列表的文本文件,并将其转换为Git,然后使用gitclone--bare将其转换成Git存储库:
#!/bin/bash
file="list.txt"
while IFS= read -r repo_name
do
printf '%s\n' "$repo_name"
sudo git svn clone --shared --preserve-empty-dirs --authors-file=users.txt file:///programs/svn/$repo_name
sudo git clone --bare /programs/git/$repo_name $repo_name.git
sudo chown -R www-data:www-data $repo_name.git
sudo rm -rf $repo_name
done <"$file"
list.txt的格式为:
repo1_name
repo2_name
users.txt的格式为:
(无作者)=罗杰斯王子<prince.rogers.nelson@payesley.park.org>
www数据是Apache web服务器用户,需要权限才能通过HTTP推送更改。