How do I resolve a git-svn index mismatch?

2020-02-08 07:20发布

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?

10条回答
放我归山
2楼-- · 2020-02-08 07:46

Update git client and refetch last svn commits using:

git svn reset -r 12345
git svn rebase

where 12345 is existing svn revision.

查看更多
【Aperson】
3楼-- · 2020-02-08 07:47

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

查看更多
家丑人穷心不美
4楼-- · 2020-02-08 07:52

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.

查看更多
Viruses.
5楼-- · 2020-02-08 07:56

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 !

查看更多
登录 后发表回答