繁体   English   中英

如何使用reposurgeon将svn repo转换为git?

[英]How do I convert an svn repo to git using reposurgeon?

你能举一个例子,我如何添加旧svn的路径并从中创建一个git文件夹,其中包含整个历史记录和所有分支/标签?

我发现这个网站值得一试吗? 它使用svnpull ,这不是我的系统,我可以使用repopuller吗?

我安装了reposurgeon

apt-get install --no-install-recommends xmlto asciidoc unp
wget http://www.catb.org/~esr/reposurgeon/reposurgeon-3.7.tar.gz
unp reposurgeon-3.7.tar.gz
cd reposurgeon-3.7
make
make install

(我会在没有建议的情况下安装,因为这里不需要大约700MB)

看起来这个网站有点过时了。

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

我过滤掉.gitignore文件,就像githubfilter-branch 记录的那样 ,否则,他们将在所有标签中创建提交(参见下面的注释)。 完成后,您必须创建一个新的.gitignore文件。

这可能需要一段时间,因此您应该在tmuxscreen内启动它

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"

并使用此脚本从所有历史记录中删除它: 如何完全删除包含空格的SVN标记?

然后我开始使用脚本:

rm $PROJECT-mirror/ $PROJECT-git/ -Rf
bash /usr/local/sbin/reposurgeon-convert-svn2git

注意:
在没有删除.gitignore文件的情况下, 除了一件事之外 ,它在git中与SVN中的内容完全相同 :所有标记在日志中按照标记的确切日期排序,而不是它们开始广告的提交。 似乎在转换过程中将.gitignore文件添加到每个分支和标记,但是.gitignore文件导致在这些标记内部提交标记创建的时间戳。
新标签没问题,它们出现在它们所属的修订版中。 (请参阅将SVN存储库转换为带有reposurgeon的git而不创建.gitignore文件?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM