Search code examples
gitsvnindexinggit-svnrebase

How do I resolve a git-svn index mismatch?


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?


Solution

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