Fatal error unpacking a tree object during a git svn fetch

When running get svn fetch to pull the latest new branches from the upstream svn repository I got this error:

$ git svn fetch
fatal: failed to unpack tree object 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d
read-tree 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d: command returned error: 128

Now every attempt at git svn on that local repo results in the same error. Originally I was running git version and after the error I tried updating to and the problem still persists.

  • SmartGit: File or Directory out of date error message when it is not?
  • git diff file against its last change
  • How to clone all projects of a group at once in GitLab?
  • Remove and ignore all files that have an extension from a git repository
  • Is there an equivalent to git stash in perforce?
  • Migrate from Subversion to git, clone all branches and push through gitolite?
  • Is there any way to clean up this corruption? A fresh git svn clone of the upstream repository is fine, but I’d like to preserve my existing setup. I’ve looked through the docs and googled for the problem with no luck.

  • git returns http error 407 from proxy after CONNECT
  • What is the proper git workflow for basing a project off a 'seed' repo?
  • Nested git repositories without remotes (a.k.a. git submodule without remotes)
  • Merging pull requests together
  • GitHub - setup auto deployment with remote server
  • Force git to run post-receive hook, even if everything is “up-to-date”
  • 3 Solutions collect form web for “Fatal error unpacking a tree object during a git svn fetch”

    I had the same problem. It is due to a particular SVN revision that git-svn can’t read or deal with somehow. Here is what i tried in order:

    1. Rewind to a revision known to work: git svn reset -r 42
    2. Retry the fetch: git svn fetch — Fetches each revision starting from 42 until the guilty one (say 50), then shows the same error message.
    3. Fetch the parent: git svn fetch --parent — Don’t ask me why. That fetches more revisions. No idea whether it’s relevant though.
    4. Retry the fetch: git svn fetch — Still doesn’t work.
    5. Fetch each of the next revisions:
      1. git svn fetch -r 50 — Works.
      2. git svn fetch -r 51 — While no error message, go on.
      3. git svn fetch -r xx — The error message shows up, it’s the bad revision. Don’t care.
      4. git svn fetch -r xx+1 — Works.
    6. Retry the fetch: git svn fetch — Works! Starts to fetch more revisions.

    The process ought to be cleaned up (probably near the first steps), but it worked for me, without having to start again with a fresh clone.

    The most likely cause for this is a file or commit (that the tree references) is corrupted or missing. Or the tree itself could be corrupted. Check with:

    git fsck --unreachable HEAD $(cat .git/refs/heads/*)

    This will show a bunch of “dangling” files, which you don’t care about; corrupted files will report “Invalid SHA1” or some such thing. I don’t know how a missing file would report. Remove any corrupt items and rsync from your upstream repo to replace them.

    I experienced the same error message after creating a new SVN branch. I was able to resolve the issue by deleting the complete “.git/svn” directory and fetching from SVN again:

    $ rm -rf .git/svn
    $ git svn fetch
    Rebuilding .git/svn/refs/remotes/trunk/.rev_map.1d5df120-ff1b-4f4f-af56-171ecbcc785d ...

    This fetched all commits from SVN again and resolved the error.

    Git Baby is a git and github fan, let's start git clone.