Git-svn问题

4

是否可以克隆一个具有多个修订版本的git存储库?我们尝试过,但在第1000次提交后进行了GC并退出,导致克隆处于不可用状态。

r998 = a5cb4f6a377b0ca80cd95d73b0e32f0552b9cdfd (git-svn)
M   trunk/asdf/asdf.java
r999 = a87b06ae8aa497bb28c294b7ff8668ce2e4c8fcc (git-svn)
D   tags/sdafasdf/asdfasdf.java
r1000 = 20b383d138499eee4f121079ae059458f3facc94 (git-svn)
Auto packing your repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 18103, done.
Compressing objects:  61% (10590/17116)      7116)   
Compressing objects: 100% (17116/17116), done.
Writing objects: 100% (18103/18103), done.
Total 18103 (delta 9301), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.
root@host:~#

尝试通过再次输入命令继续结账会导致以下结果:
root@host:~/repo# git svn clone https://host/svn/repo
Remote ref refs/remote/git-svn is tracked by
  "svn-remote.svn.fetch=:refs/remotes/git-svn"
and
  "svn-remote.svn.fetch=:refs/remotes/git-svn"
Please resolve this ambiguity in your git configuration file before continuing
3个回答

6

已找到答案。在使用Ubuntu自带的git版本时可能存在某种错误。以下这行代码会在新创建的.git/config文件中重复出现:

svn-remote.svn.fetch=:refs/remotes/git-svn
svn-remote.svn.fetch=:refs/remotes/git-svn

去除重复的内容后,我可以输入 git svn fetch 命令,这似乎使得检出继续进行。


1
我认为这是因为您尝试重新运行的命令是"svn clone",它基本上是"svn init"后跟"svn fetch"。所以我应该说"重新运行git svn fetch"。我曾经遇到过这样的问题,以至于养成了手动执行init然后fetch的习惯。 - Lachlan
我认为你是正确的。我必须质疑这个想法,即git命令可以将实际上已经损坏的内容放入配置文件中。如果新的git用户意外地输入了错误的命令,它不应该完全破坏仓库。(除非他们本来就是要把它搞崩) - corydoras
我发现当 git svn init 失败时,你必须删除 .git 文件夹(或清理.git/config)。否则下一次初始化也会失败。 - florisla

2
这种情况我经常遇到。我只需再次运行完全相同的git命令,它就会从上次停止的地方继续执行。最终它会完成所有工作并正常结束。
编辑:如果在运行git svn clone ...时出现此问题,则需要将clone替换为fetch后重新运行该命令。

我尝试了这个,但是它失败了,并显示以下信息:错误:键 svn-remote.svn.fetch 的值超过一个::refs/remotes/git-svn。 - l0b0
1
请检查您的 .git/config 文件中的 [svn-remote "svn"] 部分,并确保 fetch 条目(或条目)看起来正确。 - Lachlan
重新运行该命令会产生与“l0b0”相同的错误。 - corydoras

1

可以。这应该能正常工作。我使用以下命令克隆了Mono项目存储库(超过140k个版本):

$ mkdir mono
$ cd mono
$ git init
$ git svn init svn+ssh://foo@mono-cvs.ximian.com/source
$ git config svn-remote.svn.fetch trunk/mono:refs/remotes/git-svn/trunk
$ git config svn-remote.svn.branches branches/*/mono:refs/remotes/git-svn/branches/*
$ git config svn-remote.svn.tags tags/*/mono:refs/remotes/git-svn/tags/*
$ git fetch git://repo.or.cz/mono.git refs/heads/master:refs/remotes/git-svn/trunk refs/heads/branches/*:refs/remotes/git-svn/branches/* refs/tags/*:refs/remotes/git-svn/tags/*
$ git reset --hard git-svn/trunk

一切都进行得很好。这与你正在做的事情类似吗?


哈哈,那跟我正在做的完全不一样。看起来超出了我的 Git 技能水平 (: - corydoras
所有额外的参数只是为了支持在 Git 中将子版本控制中的所有分支和标签都变成不同的分支。你可以跳过这些。没有任何魔法涉及 :) - Gonzalo

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