Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 665
yasouser Avatar asked Nov 01 '10 23:11

yasouser


People also ask

Can you use Git and SVN together?

git-svn is a specialized tool for Git users to interact with Git repositories. It works by providing a Git frontend to an SVN backend. With git-svn, you use Git commands on the local repository, so it's just like using normal Git. However, behind the scenes, the relevant SVN commands are sent to the server.

How does Git SVN work?

git svn is a git command that allows using git to interact with Subversion repositories. git svn is part of git, meaning that is NOT a plugin but actually bundled with your git installation. SourceTree also happens to support this command so you can use it with your usual workflow.


2 Answers

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.

like image 185
Matt Hulse Avatar answered Sep 19 '22 07:09

Matt Hulse


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.

like image 26
Matthew Buckett Avatar answered Sep 17 '22 07:09

Matthew Buckett