【问题标题】:How do I convert an svn repo to git using reposurgeon?如何使用 reposurgeon 将 svn repo 转换为 git?
【发布时间】:2014-03-27 22:28:40
【问题描述】:

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

我找到了this site,这值得一试吗?它使用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)

【问题讨论】:

标签: git svn converter reposurgeon


【解决方案1】:

这个网站好像有点过时了。

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 文件。

这可能需要一段时间,所以你应该在 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"

并使用此脚本将其从所有历史记录中删除: 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?

【讨论】:

  • 我使用了搅拌机和螺母转换作为示例如何使用该工具。但是,是的,文档留下了一点希望。最好看代码。
  • @0xC0000022L:那么您是否设法在正确的位置(日期)使用标签分支转换它?
  • 到目前为止,是的。但我在 Git 存储库中使用来自 master 的版本。很可能存在差异。要更改标签名称,您可以使用 filter 操作。它对我有用,尽管我仍然必须让path 像宣传的那样工作:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-21
  • 2018-02-26
  • 2020-11-06
  • 2019-10-02
  • 1970-01-01
相关资源
最近更新 更多