git-svn 无法创建分支来遵循 SVN 分支

发布于 2024-10-11 05:56:57 字数 1299 浏览 2 评论 0原文

我正在努力解决以下问题。当我继续从 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. 删除与该分支相关的整个历史记录。也没有成功:(

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

I'm struggling with the following issue. When I continue fetching revisions from SVN with

git svn fetch

I'm getting the following error:

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

This happened because I was fetching revisions using the default filter for SVN branches:

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

Now, I have the line below added, but it's too late:

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

I have tried to fix this by using git svn reset to remove all the commits. Actually I can see from the error message that git is trying right thing, but cannot because of the branch remotes/deep being existing.

I have tried to search for 2 possible solutions:
1. Remove that branch (remotes/deep), but as it is tracked by git as a remote, I was not able to find any solution for that.
2. Remove the whole history related to that branch. No success too :(

Does anybody know how to deal with my issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

濫情▎り 2024-10-18 05:56:57

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

  1. 从 Packed-refs 中删除 refs/remotes/deep
  2. 删除 .git/logs/refs/remotes/deep

但仍然存在提取问题。我需要用于

branches = branches/*:refs/remotes/*

普通分支和

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

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

到目前为止,我通过手动注释第一个“分支”并获取具有深层分支的特定修订来做到这一点,但这不是一个好的选择,因为这两种情况都有太多的修订需要获取。

UPD:对于剩下的问题,我找到了简单但不优雅的解决方案。我使用分支来指定深层分支的路径,并使用获取来指定第一级的每个分支。

I've been finally able to fix the issue by performing the following 2 steps:

  1. Removing refs/remotes/deep from packed-refs
  2. Removing .git/logs/refs/remotes/deep

But still have the issue with fetching. I need to use

branches = branches/*:refs/remotes/*

for normal branches and

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

for deep branches. Unfortunately the former specification includes the later, so I'm getting the error "fatal: Cannot lock the ref 'refs/remotes/deep'" as git-svn tries to create deep branch according to the first spec.

So far, I do that by manually commenting the first "branches" and fetching specific revisions with deep branches, but this is not a good options as there are too many revisions to fetch for both cases.

UPD: I have found the simple but not elegant solution for the remaining issue. I'm using branches to specify paths to deep branches and fetch to specify every branch of the first level.

孤君无依 2024-10-18 05:56:57

我有一个非常类似的问题,发现“git svn重置”,而不是“git重置”修复了它。如果您没有事先更新分支配置,那么一旦您检索到通过分支点的提交,您就必须备份才能再次检索它们。否则他们就会在没有父母的情况下晃来晃去。

因此,像以前一样更新您的分支,然后

git svn reset -r<revisionnum>

像平常一样运行并遵循 git svn fetch 。这节省了我从 SVN 重建整个系统的时间。

在您的情况下,您可能还需要研究“忽略”功能,以免追踪您的嵌入式分支。

I had a very similar problem, and found that "git svn reset", not "git reset" fixed it. If you don't update your branches configuration beforehand, once you retrieve a commit that passes a branch point, you have to back up to retrieve them again. Otherwise they are dangling with no parent.

So, update your branches as before, then run

git svn reset -r<revisionnum>

and follow with your git svn fetch as normal. This saved me many hours of rebuilding the entire thing from SVN.

In your case you probably also need to investigate the "ignore" features to not trace down your embedded branch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文