如何解决 git-svn 索引不匹配的问题?

发布于 2024-09-30 12:46:01 字数 507 浏览 1 评论 0原文

当我执行 git svn rebase 时,它​​在某一点停止说:

索引不匹配:一棵树的 SHA 密钥!=另一棵树的 SHA 密钥。 (我开始知道这些 SHA 密钥对应于一棵树而不是来自 git show 的上述两个 sha 键的提交。)

re-reading <sha index of a commit in svn/trunk>
... list of files ...
fatal: bad object <SHA1 index of the bad object>
rev-list -1 <SHA1 index of the bad object> --not <SHA1 index of the revision it was trying to re-read>: command returned error: 128

我对 git 的内部工作经验不是很丰富,那么是否有一系列步骤可以遵循来剖析此类问题并可能解决它们?

When I did a git svn rebase it stopped at one point saying:

Index mismatch: SHA key of a tree != SHA key of another tree. (I come to know that these SHA keys corresponds to a tree and not a commit from git show of the above two sha keys.)

re-reading <sha index of a commit in svn/trunk>
... list of files ...
fatal: bad object <SHA1 index of the bad object>
rev-list -1 <SHA1 index of the bad object> --not <SHA1 index of the revision it was trying to re-read>: command returned error: 128

I am not very experienced in the internal workings of git, so is there a sequence of steps to follow to dissect problems like these and possibly resolve them?

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

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

发布评论

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

评论(10

梦归所梦 2024-10-07 12:46:01

请不要删除 .git/svn 文件夹来修复此问题。它要求您重建所有内容,这很烦人,需要一段时间(对于我的存储库的大小而言需要几个小时),而且没有必要。

我在这里找到了正确的答案我已将其包含在下面。

从链接:

在 .git 目录中运行以下命令:

$ find . -exec grep -Hin 5b32d4ac2e03a566830f30a702523c68dbdf715b {} \;
Binary file ./svn/.caches/lookup_svn_merge.db matches
Binary file ./svn/.caches/check_cherry_pick.db matches

现在从第一个命令的输出中删除匹配的 .svn/.caches

$ rm ./svn/.caches/lookup_svn_merge.db
$ rm ./svn/.caches/check_cherry_pick.db

现在 git svn rebasegit svn fetch 随心所欲。

Please don't remove the .git/svn folder to fix this. It requires you to rebuild everything, it is annoying, it will take awhile (for the size of my repo several hours) and it is NOT NECESSARY.

I found the right answer here and I've included it below.

From the link:

Inside the .git directory run the following:

$ find . -exec grep -Hin 5b32d4ac2e03a566830f30a702523c68dbdf715b {} \;
Binary file ./svn/.caches/lookup_svn_merge.db matches
Binary file ./svn/.caches/check_cherry_pick.db matches

Now delete the matching .svn/.caches from the output of the first command

$ rm ./svn/.caches/lookup_svn_merge.db
$ rm ./svn/.caches/check_cherry_pick.db

Now git svn rebase or git svn fetch to your heart's content.

做个少女永远怀春 2024-10-07 12:46:01

我已经遇到过两次此错误,两次都通过删除 .git 文件夹内的 svn 文件夹来解决它。

rm -r .git/svn

重建 svn 元数据:

git svn fetch

您可能会看到一条消息:

Migrating from a git-svn v1 layout...
Data from a previous version of git-svn exists, but
    .git/svn
    (required for this version (1.7.0.4) of git-svn) does not exist.
Done migrating from a git-svn v1 layout

然后用以下命令

I've had this error twice and both times resolved it by removing the svn folder inside the .git folder.

rm -r .git/svn

then rebuild the svn metadata with:

git svn fetch

You will probably see a message along the lines of:

Migrating from a git-svn v1 layout...
Data from a previous version of git-svn exists, but
    .git/svn
    (required for this version (1.7.0.4) of git-svn) does not exist.
Done migrating from a git-svn v1 layout

and after while (rebuilding can take a while especially on large repositories) you should end up with a working mirror of the svn repository again.

温馨耳语 2024-10-07 12:46:01

更新 git 客户端并使用以下命令重新获取最后的 svn 提交:

git svn reset -r 12345
git svn rebase

其中 12345 是现有的 svn 修订版。

Update git client and refetch last svn commits using:

git svn reset -r 12345
git svn rebase

where 12345 is existing svn revision.

月朦胧 2024-10-07 12:46:01

就我而言,该问题是由新的/未知的 svn 作者引起的,他不在我的 git-svn 配置使用的 authors 文件中。它在输出中报告说,我忽略了前几​​个读取:

Index mismatch: <leftsha1> != <rightsha1>
rereading <anothersha1>
        ... list of files ...
Author: <name> not defined in /path/to/authors file

因此,这给了我丢失的名称,以及要添加的文件(我从组织用户注册表中提取了电子邮件),一切顺利。

In my case, the issue was caused by a new/unknown svn author who was not in my authors file that git-svn was configured to use. It reported it in the output that that I ignored the first few reads:

Index mismatch: <leftsha1> != <rightsha1>
rereading <anothersha1>
        ... list of files ...
Author: <name> not defined in /path/to/authors file

So that gave me the name that I was missing, and what file to add it too (I pulled the email from my organizations user registry) and was smooth sailing.

醉酒的小男人 2024-10-07 12:46:01

问题是,在这种情况下,你必须系统地执行此操作:

  • 使用 git + svn
  • 在 svn 上创建分支,使用 git-svn
  • 将分支合并到主干,使用 svn 工具
  • 删除 svn 分支,
  • 执行 git-svn rebase

缺少一些东西,一切崩溃。我知道恢复的唯一方法是删除 .git 中的所有 svn 并重建所有内容。这只是烦人并且需要一段时间!

The problem there is that you have to do this systematically in this case :

  • use git + svn
  • create branch on svn with git-svn
  • merge branch to trunk with svn tools
  • remove the svn branch
  • do a git-svn rebase

Something missing, everything crash. The only way I know to recover is do remove all svn in .git and rebuild everything. It's just annoying and take a while !

一口甜 2024-10-07 12:46:01

很可能,您的消息中也可能同时存在校验和不匹配:

我在这里找到了解决方案 Git svn变基:校验和不匹配

git svn log <item with checksum mismatch>
git svn reset -r<top history revision in the log> -p
git svn rebase

Likely, you may also have Checksum mismatch at the same time in your message:

I found solution here Git svn rebase : checksum mismatch:

git svn log <item with checksum mismatch>
git svn reset -r<top history revision in the log> -p
git svn rebase
策马西风 2024-10-07 12:46:01

我自己刚刚遇到了这个错误。只需删除引用,如下所示:

rm .git/refs/remotes/git-svn

这应该会清除错误。

I just had this error myself. Just delete the ref, like so:

rm .git/refs/remotes/git-svn

That should clear up the error.

吻泪 2024-10-07 12:46:01

也许与文件系统(ext4/btrfs/etc...)的写时复制功能有关?

请参阅:https://stackoverflow.com/a/42299634/7491491

Maybe something to do with Copy-On-Write feature of your filesystem (ext4/btrfs/etc...) ?

See : https://stackoverflow.com/a/42299634/7491491

清风夜微凉 2024-10-07 12:46:01

我收到此错误:

索引不匹配:!= <煞>;
重新读取;
...文件列表...
<路径>在提交中找不到(r)

在 SVN 存储库中查看报告路径的历史记录,我找到了添加该文件的 SVN 修订版。但在 Git 中查看为该修订创建的提交时,我发现它不包含任何文件!

我认为这是由之前的磁盘已满引起的。在执行 git svn reset -r 回到损坏的 Git 提交的修订版本后,git svn fetch 再次正常工作。

I got this error:

Index mismatch: <sha> != <sha>
re-reading <sha index of a commit in svn/trunk>
... list of files ...
<path> was not found in commit <sha> (r<svn rev>)

Looking in SVN repo at the history of the reported path, I found the SVN revision where the file had been added. But looking in Git at the commit created for that revision I found that it didn't contain any files!

I think this had been caused by a full disk earlier. After doing a git svn reset -r back to the revision of the broken Git commit, git svn fetch worked fine again.

余生再见 2024-10-07 12:46:01

我在最初的克隆过程中遇到了这个问题,结果有人创建了一个名为 trunk 的分支,它与真正的主干冲突。忽略 /branches/trunk 后一切正常

I ran into this during the initial cloning turns out someone created a branch called trunk which conflicted with the real trunk. After ignoring /branches/trunk all worked

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