git-svn无法创建跟随SVN分支的分支

时间:2011-01-09 11:33:23

标签: git git-svn

我正在努力解决以下问题。当我继续使用

从SVN获取修订版时
git svn fetch

我收到以下错误:

Found possible branch point: https://somecompany.com/product/trunk
=> https://somecompany.com/product/branches/deep/branches/product-001, 72666 
Found branch parent: (refs/remotes/deep/branches/product-001) b685b7b92813885fdf 6b8e2663daf884bf504b14
Following parent with do_switch 
Successfully followed parent 
error: 'refs/remotes/deep' exists; cannot create 'refs/remotes/deep/branches/product-001'
fatal: Cannot lock the ref 'refs/remotes/deep/branches/product-001'.
update-ref -m r72667 refs/remotes/deep/branches/product-001 df51920e8f0a53f26507 c2679eb6a9dbad91e0d6: command returned error: 128

发生这种情况是因为我使用SVN分支的默认过滤器获取修订:

[svn-remote "svn"]
    url = https://somecompany.com/someproduct
    fetch = trunk:refs/remotes/trunk
    branches = branches/*:refs/remotes/*
    tags = tags/*:refs/remotes/tags/*

现在,我已添加以下行,但为时已晚:

branches = branches/deep/branches/*:refs/remotes/deep/branches/*

我试图通过使用git svn reset来删除所有提交来解决这个问题。实际上我可以从错误信息中看到git正在尝试正确的事情,但不能因为分支遥控/深层存在。

我试图寻找两种可能的解决方案: 1.删​​除那个分支(远程/深),但由于它被git跟踪为远程,我无法找到任何解决方案。 2.删除与该分支相关的整个历史记录。也没有成功:(

有人知道如何处理我的问题吗?

2 个答案:

答案 0 :(得分:4)

我终于可以通过执行以下两个步骤来解决问题:

  1. 从packed-refs中删除refs / remotes / deep
  2. 删除.git / logs / refs / remotes / deep
  3. 但仍然存在提取问题。我需要使用

    branches = branches/*:refs/remotes/*
    

    用于普通分支和

    branches = branches/deep/branches/*:refs/remotes/deep/branches/*
    

    深层分支。不幸的是前一个规范包括后者,所以我得到错误“致命:无法锁定ref'refs / remotes / deep'”,因为git-svn试图根据第一个规范创建深分支。

    到目前为止,我通过手动注释第一个“分支”并使用深分支获取特定修订来实现这一点,但这不是一个好的选项,因为对这两种情况的获取修改过多。

    UPD:我发现了剩下的问题的简单但不优雅的解决方案。我正在使用分支来指定深分支的路径,并使用fetch来指定第一级的每个分支。

答案 1 :(得分:1)

我有一个非常类似的问题,发现“git svn reset”,而不是“git reset”修复它。如果您未事先更新分支配置,则在检索通过分支点的提交后,您必须备份以再次检索它们。否则他们就没有父母了。

所以,像以前一样更新你的分支,然后运行

git svn reset -r<revisionnum>

并正常跟随你的git svn fetch。这让我节省了很多时间从SVN重建整个东西。

在您的情况下,您可能还需要调查“忽略”功能,以便不追踪嵌入式分支。