简体   繁体   English

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

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

Can you give an example, how I add the path to my old svn and create a git folder from it, that contains the whole history and all branches/tags? 你能举一个例子,我如何添加旧svn的路径并从中创建一个git文件夹,其中包含整个历史记录和所有分支/标签?

I found this site is this worth a try? 我发现这个网站值得一试吗? It uses svnpull , which is not on my system can I use repopuller instead? 它使用svnpull ,这不是我的系统,我可以使用repopuller吗?

I installed reposurgeon with 我安装了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

(I would install without the recommendations, cause that would be about 700MB not needed here) (我会在没有建议的情况下安装,因为这里不需要大约700MB)

It seems like the site is a bit outdated. 看起来这个网站有点过时了。

svnpull is replaced by repopuller by now. svnpull现在被repopuller取代。 And you don't need that either if you are on the same server. 如果你在同一台服务器上,你也不需要它。

I adapted the script: 我改编了剧本:

nano /usr/local/sbin/reposurgeon-convert-svn2git

and entered: 并输入:

#!/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

I filter out the .gitignore files like github has documented with filter-branch because otherwise, they will create commits in all tags (see note below). 我过滤掉.gitignore文件,就像githubfilter-branch 记录的那样 ,否则,他们将在所有标签中创建提交(参见下面的注释)。 You have to create a new .gitignore file when you are done. 完成后,您必须创建一个新的.gitignore文件。

This may take a while, so you should start it inside tmux or screen with 这可能需要一段时间,因此您应该在tmuxscreen内启动它

tmux
bash /usr/local/sbin/reposurgeon-convert-svn2git

Take care, that all your tags are git conform. 请注意,所有标签都符合git。

I got the error 我收到了错误

reposurgeon% reposurgeon: exporting...fatal: Branch name doesn't conform to GIT standards: refs/tags/version 3.6.2

So I cleaned up the svn repository and removed this branch, so all tags and branches are conform: 所以我清理了svn存储库并删除了这个分支,所以所有的标签和分支都符合:

svn rm "$svnrepo/tags/version 3.6.2"

and deleted it from all history with this script: How do I remove an SVN tag completely that contains spaces? 并使用此脚本从所有历史记录中删除它: 如何完全删除包含空格的SVN标记?

Then I started over with the script: 然后我开始使用脚本:

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

Note: 注意:
Without removing the .gitignore files, it looks all the same in git as in SVN before except one thing : all tags are ordered in the log at the exact date they were tagged, instead of the commit they started ad. 在没有删除.gitignore文件的情况下, 除了一件事之外 ,它在git中与SVN中的内容完全相同 :所有标记在日志中按照标记的确切日期排序,而不是它们开始广告的提交。 It seems a .gitignore file is added there in the conversion process to each branch and tag, but that .gitignore-file results in a commit inside those tags with the timestamp of the tag-creation. 似乎在转换过程中将.gitignore文件添加到每个分支和标记,但是.gitignore文件导致在这些标记内部提交标记创建的时间戳。
New tags are ok, they appear right at the revision they belong to. 新标签没问题,它们出现在它们所属的修订版中。 (see Convert an SVN repository to git with reposurgeon without creating .gitignore files? ) (请参阅将SVN存储库转换为带有reposurgeon的git而不创建.gitignore文件?

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

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