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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4073956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:41:47  来源:igfitidea点击:

How do I resolve a git-svn index mismatch?

gitsvnindexinggit-svnrebase

提问by yasouser

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

当我执行 git svn rebase 时,它​​一度停下来说:

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.)

Index mismatch: SHA key of a tree != SHA key of another tree.(我开始知道这些 SHA 密钥对应于一棵树,而不是来自上述两个 sha 密钥的 git show 提交。)

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?

我对 git 的内部工作不是很有经验,所以是否有一系列的步骤来剖析这些问题并可能解决它们?

回答by Matthew Buckett

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

我遇到过两次这个错误,两次都通过删除 .git 文件夹中的 svn 文件夹来解决它。

rm -r .git/svn

then rebuild the svn metadata with:

然后使用以下命令重建 svn 元数据:

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.

一段时间后(重建可能需要一段时间,尤其是在大型存储库上),您应该再次获得 svn 存储库的工作镜像。

回答by Matt Hulse

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.

请不要删除 .git/svn 文件夹来解决这个问题。它需要您重建所有内容,这很烦人,这需要一段时间(对于我的回购几个小时的大小),而且不是必需的。

I found the right answer hereand I've included it below.

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

From the link:

从链接:

Inside the .git directory run the following:

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

$ 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

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

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

Now git svn rebaseor git svn fetchto your heart's content.

现在git svn rebasegit svn fetch您的心满意足。

回答by yarolig

Update git client and refetch last svn commits using:

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

git svn reset -r 12345
git svn rebase

where 12345 is existing svn revision.

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

回答by ThorSummoner

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

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

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.

所以这给了我我丢失的名字,以及添加它的文件(我从我的组织用户注册表中提取了电子邮件)并且一帆风顺。

回答by geistteufel

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
  • 使用 git + svn
  • 使用 git-svn 在 svn 上创建分支
  • 使用 svn 工具将分支合并到主干
  • 删除 svn 分支
  • 做一个 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 !

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

回答by Michael Melanson

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

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

rm .git/refs/remotes/git-svn

That should clear up the error.

那应该清除错误。

回答by Rapha?l Gertz

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

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

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

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

回答by oliver

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>)

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!

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

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

我认为这是由之前的完整磁盘引起的。在git svn reset -r返回对损坏的 Git 提交的修订后,git svn fetch再次正常工作。

回答by David van Laatum

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

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

回答by Sergei

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 rebase : checksum mismatch

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