fatal: git-write-tree: error building trees

2020-05-25 06:55发布

问题:

I'm trying to import a large subversion repository into git using git-svn (so that I can work in git but still dcommit to subversion from time to time). After importing more than 4000 revisions I'm now getting the following error whenever I run git svn fetch or git svn rebase, which I don't manage to get rid of:

$ git svn fetch
error: invalid object 100644 1f2....742 for 'src/path/.../file.cs'
fatal: git-write-tree: error building trees
write-tree: command returned error: 128

What I've tried so far:

  • git fsck --full doesn't report anything, neither does git fsck --unreachable or git fsck --no-reflog
  • git gc --aggressive doesn't help
  • moving the single pack file away and reimporting it with git unpack-objects doesn't help
  • git svn reset -rXY with XY a bit lower than the latest imported revsion doesn't seem to help either, neither does manually removing the latest entries from the reflog up to XY.
  • reboot. Sounds silly, but I did observe some weird issues while importing the first ~4000 revision, as if something was leaking a lot of kernel resources (most likely in windows subsystem), might be related to msys/mingw (or the avira virus scanner, which I disabled for testing).

I also didn't find out what error 128 really stands for. Any ideas? Thanks in advance!

Might be related to this question which is about error 128 as well but with different error messages, and without a solution.

msysgit version 1.6.4.msysgit.0 with bash on xp sp3

回答1:

git svn gc

(possibly git gc and git prune before)



回答2:

Short answer: Try resolving any merge conflicts, committing them, and they fetch/pull again.

Longer explanation: I'm guessing you resolved this issue, since it was posted so long ago. I'm writing this since Google's ranking of StackOverflow articles is high enough that other people with this problem would be very likely to visit this page if they had this error.

I encountered a similar error when trying to do a "git stash", what turned out to be the problem was that a merge conflict had occurred after a pull. I had not resolved & committed the conflict, and this left the repository in a state that prevented me from pulling/merging/etc...

If you make sure you don't have any blocking files, try again.

Good luck!