SVN到Git的迁移.如何将非标准SVN布局迁移到Git [英] SVN to Git Migration. How to migrate a non standard SVN layout to Git

查看:81
本文介绍了SVN到Git的迁移.如何将非标准SVN布局迁移到Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将svn源代码控制项目迁移到Git(BitBucket)中.我遵循了Atlassian的指南接近尾声,但在运行命令 git push -u origin --all 时遇到以下错误:

I am currently working on migrating an svn source controlled project into Git (BitBucket). I have followed the guide by Atlassian and nearly got to the end but encountered the following error when running the command git push -u origin --all:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date.

我相信这是因为SVN布局不是标准布局.我必须像这样指定树干,分支和标签:

I believe this is because the SVN layout is not the standard layout. I have had to specify the trunk, branches and tags like so:

git svn clone --trunk=/main --branches=/branches/Sprints/Iteration_1 --branches=/branches/Sprints/Iteration_2 --tags=/tags --authors-file=authors.txt svn://svn-project/projExample projExample

但是我不知道如何继续并将回购推送到BitBucket.任何帮助将不胜感激!

But I cannot figure out how to proceed and push the repo to BitBucket. Any help would be greatly appreciated!

值得注意的是,我尝试了命令 git push origin master 并收到以下错误:

It is also worth noting that I have tried the command git push origin master and received the below error:

error: src refspec master does not match any.
error: failed to push refs to '[my bitbucket origin]'.

我发现的上一个问题的示例是在这里.但这似乎没有帮助.也许我做错了什么?

An example of a previous question I have found is here. But this didn't seem to help. Perhaps I am doing something wrong?

下面是为了运行上述初始错误而运行的命令:

Below are the commands in order run to get to the initial error described above:

  1. java -jar/svn-migration-scripts.jar验证
  2. java -jar/svn-migration-scripts.jar作者svn://svn-project/projExample> authors.txt
  3. 编辑authors.txt文件以匹配所有当前用户名&电子邮件.
  4. git svn clone --trunk =/main --branches =/branches/Sprints/Iteration_1 --branches =/branches/Sprints/Iteration_2 --tags =/tags --authors-file = authors.txt svn://svn-project/projExample projExample
  5. java -DFile.encoding = utf-8 -jar/svn-migration-scripts.jar clean-git --force
  6. git svn提取
  7. java -Dfile.encoding = utf-8 -jar/svn-migration-scripts.jar sync-rebase
  8. java -Dfile.encoding = utf-8 -jar/svn-migration-scripts.jar clean-git --force
  9. git远程添加来源 https://example@bitbucket.com/projExample.git
  10. git push -u origin --all
  11. 什么都没发生.

推荐答案

经过反复试验,我得出的结论是,此处使用的SVN结构过于复杂.我将命令更新为

After a lot of trial and error I have come to the conclusion that the SVN structure used here was just far too complicated. I updated the command to

git svn clone --trunk=main --branches=branches/*/* --tags=tags/* --authors-file=authors.txt svn://svn-project/projExample projExample

这解决了问题,但导致命令需要7天才能运行!这表明结构太复杂了!

Which solved the issue but resulted in the command taking 7 days to run! This shows that the structure was far too complicated!

因此,我决定使用包含最新代码的svn分支作为主干,该分支成功添加了历史记录但未创建所需的分支.我认为这已经足够好了,因为该命令将在2小时内运行.我执行的命令更像是这样:

As a result of this I decided to use the svn branch containing the latest code as the trunk which successfully added the history but did not create the required branches. I decided that this was good enough as the command would run within 2 hours. The command I went for was more like this:

git svn clone --trunk=branches/Sprints/Iteration_2 --authors-file=authors.txt svn://svn-project/projExample projExample.

如果我为此建议他人,我会说直接执行上面的命令,因为它很快并且可以完成工作!

If I was advising someone else on this I would say to go straight for the command above as it is quick and does the job!

以下是将SVN同步到Git存储库所需的命令.基本上,您需要将Origin/trunk和master合并,然后按入

As an extra below are the commands needed to sync SVN to the Git repo. basically you need to merge origin/trunk and master and then push

git svn fetch
git merge origin/trunk
git push origin master

这篇关于SVN到Git的迁移.如何将非标准SVN布局迁移到Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆