git 这个 svn2git 错误是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3009738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:20:42  来源:igfitidea点击:

What does this svn2git error mean?

svngitgit-svn

提问by Hisham

I am trying to import my repository from svn to git using svn2git, but it seems like it's failing when it hits a branch. What's the problem?

我正在尝试使用 svn2git 将我的存储库从 svn 导入到 git,但它似乎在遇到分支时失败了。有什么问题?

Found possible branch point: https://s.aaa.com/repo/trunk/project => https://s.aaa.com/repo/branches/project-beta1.0, 128
Use of uninitialized value in substitution (s///) at /opt/local/libexec/git-core/git-svn line 1728.
Use of uninitialized value in concatenation (.) or string at /opt/local/libexec/git-core/git-svn line 1728.
refs/remotes/trunk: 'https://s.aaa.com/repo' not found in ''

Running command: git branch -l --no-color
* master
Running command: git branch -r --no-color
  trunk
Running command: git checkout trunk
Note: checking out 'trunk'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at f4e6268... Changing svn repository in cap files
Running command: git branch -D master
Deleted branch master (was f4e6268).
Running command: git checkout -f -b master
Switched to a new branch 'master'
Running command: git gc
Counting objects: 450, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (368/368), done.
Writing objects: 100% (450/450), done.
Total 450 (delta 63), reused 450 (delta 63)

回答by bkrishnan

I had to open up the .git/config file and delete all the branches and tags entries under the svn-remote section and run the 'git svn clone' command for this error to go away. Apparently, if I run this command multiple times (usually stop and re-start from a revision), the branch/tag entries get added to the config file instead of being reused, which causes the error.

我必须打开 .git/config 文件并删除 svn-remote 部分下的所有分支和标签条目,然后运行“git svn clone”命令以消除此错误。显然,如果我多次运行此命令(通常停止并从修订版重新启动),分支/标签条目将被添加到配置文件中,而不是被重用,这会导致错误。

回答by nemoo

To fix your problems you have to convert the imported remote branches and tags to local ones.

要解决您的问题,您必须将导入的远程分支和标签转换为本地分支和标签。

Section from Scott Chacone (PRO GIT): Original link: http://progit.org/book/ch8-2.html:

Scott Chacone (PRO GIT) 的部分:原始链接:http: //progit.org/book/ch8-2.html :

To move the tags to be proper Git tags, run

$ cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/tags

This takes the references that were remote branches that started with tag/ and makes them real (lightweight) tags.

Next, move the rest of the references under refs/remotes to be local branches:

$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

This worked for me perfectly.

这对我来说非常有效。

回答by jaolho

I was following some svn to git instructionswhen I ran into the same error message. The error occurred when I ran this command:

当我遇到相同的错误消息时,我正在遵循一些 svn 到 git指令。运行此命令时发生错误:

git svn clone file:///pathto/repo /pathto/new-git-repo –-no-metadata -A authors.txt -t tags -b branches -T trunk

After the error occurred, I edited the .git/config-file as follows:

发生错误后,我编辑了 .git/config-file 如下:

tags = tags/*:refs/remotes/svn/tags/*
branches = branches/*:refs/remotes/svn/*

->

->

tags = tags/*:refs/remotes/svn/tags/*
branches = branches/*:refs/remotes/svn/branches/*

I.e., I just formatted the "braches" line to be similar to the "tags" line. Then I ran the command again. The process produced a valid git repo with remote branches.

即,我只是将“braches”行格式化为类似于“tags”行。然后我再次运行命令。该过程生成了一个带有远程分支的有效 git 存储库。

回答by Adam Dymitruk

Your subversion repository does not have a standard trunk/branches/tags structure. Specify the alternate places for where you branched by using the --branch, --tag, --trunk options.

您的 subversion 存储库没有标准的主干/分支/标签结构。使用 --branch、--tag、--trunk 选项指定分支位置的备用位置。

回答by Christian

It seems svn2git doesn't pass the branch configuration correctly. I had the standard layout but the error occurred. I fixed it with passing the defaults for the layout again:

似乎 svn2git 没有正确传递分支配置。我有标准布局,但发生了错误。我通过再次传递布局的默认值来修复它:

$ svn2git http://repos --branches branches --tags tags --trunk trunk

Then it worked as expected.

然后它按预期工作。