【问题标题】:git-svn clone fails "fatal: Not a valid object name"git-svn 克隆失败“致命:不是有效的对象名称”
【发布时间】:2012-07-06 15:37:19
【问题描述】:

在执行git svn clone -s https://svn.example.com/repo/ 时,我收到以下输出:

r3073 = a6132f3a937b632015e66d694250da9f606b8333 (refs/remotes/trunk)
Found possible branch point: https://svn.example.com/repo/trunk => https://svn.example.com/repo/branches/v1.3, 3073
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
W: Refspec glob conflict (ref: refs/remotes/trunk):
expected path: repo/branches/trunk
    real path: repo/trunk
Continuing ahead with repo/trunk
fatal: Not a valid object name refs/remotes/tags/Sync Controllers
cat-file commit refs/remotes/tags/Sync Controllers: command returned error: 128

运行git branch -a 给出:

remotes/tags/Sync%20Controllers
remotes/tags/v1.1
remotes/trunk
remotes/v1.2

我认为问题在于 "remotes/tags/Sync Controllers" != "remotes/tags/Sync%20Controllers"。

【问题讨论】:

标签: git-svn


【解决方案1】:

SVN 上的标签中有一个空格,但 git 中的标签将此空格转换为%20(URL 编码)。要解决它,只需手动添加一个带有逐字名称的新标签:

cd .git/refs/remotes/tags/
mv Sync%20Controllers Sync\ Controllers

然后再次运行git svn clone 命令。

(通常你会使用git tag OLDTAG NEWTAG 来执行此操作,但 git 不允许我定义带有空格的标签。标签文件只是包含相关提交哈希的文本文件。) em>

【讨论】:

  • 我尝试了该解决方案,但出现以下错误:fatal: Reference has invalid format: 'refs/remotes/tags/WITH SPACE'。如何解决?
  • (我使用的是 git 版本 1.8.3.msysgit.0)
  • 这对我来说也适用于文件名中带有~ 字符的标签。谢谢。
  • 您好,您知道如何解决分支问题吗? stackoverflow.com/questions/33477630/…
  • 可能相同,但改为cd .git/refs/heads/cd .git/logs/refs/heads/
【解决方案2】:

您可以使用 git-svn 服务器端替代方案,SubGit 以避免许多 git-svn 翻译问题。

我是一名 SubGit 开发人员,可以说我们为解决上述字符翻译问题做了很多工作;在这种特殊情况下,标签将被转换为 refs/tags/Sync+Controllers 标签。

另请注意,git-svn 已将 Subversion 标签翻译为分支而不是标签。

【讨论】:

  • 我必须在服务器上安装 SubGit 还是没有必要?如果我没有 svn 存储库的管理员权限怎么办?
  • 使用 SubGit 2.0,您不必拥有对存储库的管理员访问权限。您需要启用 pre-revprop-change 挂钩才能获得功能齐全的作者映射,但很可能它已经启用。更多详情请查看subgit.com/eap
【解决方案3】:

我今天遇到了这个问题,认为这个分支中包含一个速度并不重要,我只是运行

git branch -r -d partialPayment%202.4

然后重新运行git svn fetch 它跳过了当前分支并继续抓取下一个分支。

【讨论】:

    【解决方案4】:

    我相信空格问题在 Git >= 1.8.0 中已修复(参见:#786942)。

    所以你应该升级它。

    我已经测试过了,它似乎可以在最新版本的 git 中工作。

    参见 GitHub 主页:https://github.com/git/git

    【讨论】:

    • 我使用的是 1.8.5.2 遇到了这个问题
    • 您认为这与您的分支/标签名称中的空格或某些特殊字符等有关吗?
    • 我在 git = 1.8.3.1, svn = 1.7.14 和 svn2git = 2.3.2 也看到过这个问题,与 SVN 分支名称中的空格有关。
    • 我有 git 版本 2.23.0,但遇到了这个问题
    【解决方案5】:

    我正在使用 git 1.29.2 并且也遇到了问题。此外,它正在运行到 Windows Server 2016 并且 git 在 cygwin 下。

    正在检查/GitMigration/.git/svn/refs/remotes/origin,该文件夹有空格而不是%20,因此无需更改。

    但是在packed-refs 中没有出现产生问题的标签,没有名称也没有哈希。

    这个问题应该有另一个与产生错误的其他相关问题,而不仅仅是这个。

    查看./.git/config 发现以下行的一系列重复:

    branches = server/branches/*:refs/remotes/origin/*
    tags = server/tags/*:refs/remotes/origin/tags/*
    

    每次我运行 git-svn 克隆语句时都会产生这种情况。所以我确实从配置文件中删除了这些,保存并再次运行,但这次使用git svn fetch,以防止再次出现重复的行,哇!问题解决了。

    【讨论】:

      猜你喜欢
      • 2014-08-15
      • 2023-04-09
      • 2017-05-26
      • 1970-01-01
      • 2011-06-11
      • 2020-04-08
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      相关资源
      最近更新 更多