这个网站好像有点过时了。
svnpull 现在被 repopuller 取代了。如果你在同一台服务器上,你也不需要。
我改编了剧本:
nano /usr/local/sbin/reposurgeon-convert-svn2git
然后输入:
#!/bin/bash
PROJECT=myproject
svnrepo=svn+ssh://rubo77@myserver.de/var/svn-repos/$PROJECT
# or something like svnrepo=https://svn.origo.ethz.ch/$PROJECT
gitrepo=/tmp/$PROJECT-git
cd /tmp
# start over with:
#rm $PROJECT-mirror/ $PROJECT-git/ -Rf
echo
echo pull/copy the repository...
#repopuller $svnrepo
# or copy it if it is on the same server:
cp -av /var/svn-repos/$PROJECT /tmp/$PROJECT-mirror
echo
echo start conversion...
reposurgeon <<EOF
read /tmp/$PROJECT-mirror
prefer git
edit
references lift
rebuild $gitrepo
EOF
echo ...finished
# now filter out all falsly generated .gitignore files:
cd $gitrepo/
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $(find . -name .gitignore|xargs )" \
--prune-empty --tag-name-filter cat -- --all
我使用 filter-branch 过滤掉像 github has documented 这样的 .gitignore 文件,否则它们会在所有标签中创建提交(请参阅下面的注释)。完成后,您必须创建一个新的 .gitignore 文件。
这可能需要一段时间,所以你应该在 tmux 或 screen 中启动它
tmux
bash /usr/local/sbin/reposurgeon-convert-svn2git
请注意,您的所有标签都符合 git。
我收到了错误
reposurgeon% reposurgeon: exporting...fatal: Branch name doesn't conform to GIT standards: refs/tags/version 3.6.2
于是我清理了svn存储库并删除了这个分支,所以所有标签和分支都符合:
svn rm "$svnrepo/tags/version 3.6.2"
并使用此脚本将其从所有历史记录中删除:
How do I remove an SVN tag completely that contains spaces?
然后我从脚本重新开始:
rm $PROJECT-mirror/ $PROJECT-git/ -Rf
bash /usr/local/sbin/reposurgeon-convert-svn2git
注意:
在不删除 .gitignore 文件的情况下,它在 git 中与在 SVN 中的外观完全相同 除了一件事:所有 标签 在日志中的确切日期排序标记,而不是他们开始广告的提交。似乎在每个分支和标签的转换过程中添加了一个 .gitignore 文件,但是 .gitignore 文件会导致在这些标签内提交带有标签创建时间戳的提交。
新标签没问题,它们出现在它们所属的修订版上。 (见Convert an SVN repository to git with reposurgeon without creating .gitignore files?)