使用svn-migration-scripts将SVN迁移到Git

4
将SVN存储库克隆到Git存储库正常运行。然而,我遇到了
问题。
java -Dfile.encoding=utf-8 -jar c:\svn-migration-scripts.jar clean-git --force

上面列出的命令应该将所有远程标记转换为本地标记。
但我收到了:
# Creating annotated tags...
tag has diverged: 1.0_RC1
Creating annotated tag '1.0_RC1' at refs/remotes/tags/1.0_RC1.
# Creating local branches...
# Checking for obsolete tags...
svn: E215004: Authentication failed and interactive prompting is disabled; see t
he --force-interactive option
svn: E215004: Unable to connect to a repository at URL 'http://127.0.0.1/svn/dri
veLearner/tags'
svn: E215004: No more credentials or we tried too many times.
Authentication failed
Deleting Git tag '1.0_RC1' not in Subversion.
Deleted tag '1.0_RC1' (was d200bf6)
# Checking for obsolete branches...
svn: E215004: Authentication failed and interactive prompting is disabled; see t
he --force-interactive option
svn: E215004: Unable to connect to a repository at URL 'http://127.0.0.1/svn/dri
veLearner/branches'
svn: E215004: No more credentials or we tried too many times.
Authentication failed
No obsolete branches to remove.
# Cleaning tag names
# Cleaning branch names

我使用本地的winXP,java版本是1.7_65,VisualSVN服务器(http,端口80)。仓库对所有人都以读/写模式开放。
有趣的是,在遇到同样的问题后,我成功地完成了其他仓库的这个过程,但我不知道我做了什么。
请问是否有人有解决方法?


很难在没有测试的情况下说。也许导入机制发生了变化,现在分支是本地的。我不知道。 - rainbow
3个回答

8

这个Atlassian的svn-migration-script.java程序很糟糕。下面是详细的说明,如何在最少使用第三方软件的情况下迁移从SVN到Git,并保留本地分支和标签。

详细教程:
[原始链接已失效] http://www.sailmaker.co.uk/blog/2013/05/05/migrating-from-svn-to-git-preserving-branches-and-tags-3/
[备选链接] https://blog.redbranch.net/2015/06/12/migrating-from-svn-to-git-with-branches-and-tags/

SVN 服务器:
url: [svn地址]/[项目名称]/[项目名称]
user: [用户名]
pass: [密码]
(用户 [用户名] 的访问权限为:读写)

目标:
c:[eclipse工作空间][项���名称] (如果不存在,则创建目录)

步骤:
++ 在系统中安装svn和git (并可选择将它们的'bin'目录添加到PATH)
++ 确保svn服务器以http模式运行 (不是https)
++ 如果需要,请创建authors.txt文件
++ 将svn克隆到git: git svn clone --stdlayout --authors-file=c:\authors.txt
[svn地址]/[项目名称] c:[eclipse工作空间][项目名称] [用户名] [密码]
如果出现映射错误,可以使用命令rebase -b 0x64000000 "c:\program files\git\bin\libsvn_repos-1-0.dll" (或类似的命令)
++ 在上下文菜单中运行Git Bash (必须安装此程序)
++ 输入命令 git branch -a 检查您的分支和标签
++ 在Git Bash中输入:

要附加分支:

for branch in `git branch -r | grep "branches/" | sed 's/ branches\///'`; do
  git branch $branch remotes/branches/$branch
done

添加标签的方法:

for tag in `git branch -r | grep "tags/" | sed 's/ tags\///'`; do
 git tag $tag remotes/tags/$tag
done

++ 创建裸的git仓库并将项目推送到仓库中(注意:此时会丢失SVN依赖)
++ 在目标位置克隆[project]项目


对此进行简短的评论。经过一段时间(我花了一点时间来熟悉Git和辅助工具),我注意到这种导入标签的方式确实创建了本地标签,但也创建了一个分支。然而,后续提交是在主分支上进行的。 - rainbow
当我想用Bash脚本附加标签或分支时,出现了这个错误:“致命错误:无法将'remotes/tags/svn/tags/...'解析为有效的引用”。 - MychaL
@rainbow的链接已经失效。 - w33haa
@w33haa,很抱歉,但我对此无能为力。这个博客不是我的。 - rainbow

1
这是我让它在Mac OSX上运行的方法:
  1. 将凭据添加到相应的~/.subversion/auth文件中
  2. 尝试运行svn log your-repo-url,只是为了查看svn身份验证是否工作
  3. 在Mac上,这会要求我使用我的钥匙串,我选择“始终允许”
  4. 之后,我的clean-git命令也开始工作了
还有一个链接记录的问题,但维护者们没有给予关注。

-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接