I'm running git fsck command on some repositories, and for 4 of them I got the same error:

error in tree b2b510c83ea553c587ebe5bc160e92cb7888393a: duplicateEntries: contains duplicate file entries
error in tree b3969ac6fe6b6359d48006e6a4cf3ffd5a4350a3: duplicateEntries: contains duplicate file entries
error in tree 5a7445940626358083a782ba5c81f956c7f82ac5: duplicateEntries: contains duplicate file entries

any idea how to fix it? what does it mean that it appears exactly the same for all?

  • Have you tried git fsck --full? Mar 1, 2020 at 0:04
  • same error as git fsck
    – arielma
    Mar 1, 2020 at 7:24

1 Answer 1


Git stores the contents of a directory in a tree object. In general, tree objects are supposed to be in sorted filename order by byte value.

This message means that those particular tree objects contain a duplicate entry, which isn't supposed to be the case. Whatever tool you're using to create these objects has created corrupt ones, and Git is now complaining.

To fix it, you should first stop using whatever tool created these problems so you don't make it worse. Then, you can run git gc --prune=now to delete unused objects immediately. You can then run git fsck to see if the commits are gone; if they're not in the history, they'll have been deleted.

If this doesn't work, then you can rewrite the repository by creating a new repository and running something like the following:

git fast-export --all | (cd /empty/repository && git fast-import)

This will necessarily rewrite some of your object IDs, but Git will not import the duplicate values when it writes the new repository.

  • Tnx! I will try it and update
    – arielma
    Mar 1, 2020 at 7:26
  • I ran the command git gc --prune=now and got: Enumerating objects: 48656, done. Counting objects: 100% (18/18), done. Delta compression using up to 16 threads Compressing objects: 100% (18/18), done. Writing objects: 100% (18/18), done. Total 18 (delta 9), reused 0 (delta 0) Computing commit graph generation numbers: 100% (9422/9422), done. afterward, I ran again git fsck but got the same errors as earlier
    – arielma
    Mar 1, 2020 at 8:52
  • BTW, when running git ls -tree on each one of the trees, I see what is duplicate: 040000 tree bedd93cf41a5d3ed9b19a2062cd7f49e930d4227 resources 040000 tree bedd93cf41a5d3ed9b19a2062cd7f49e930d4227 resources
    – arielma
    Mar 1, 2020 at 13:18
  • one more comment, I saw in one of the threads something similar to your command: git gc --aggressive --prune=now
    – arielma
    Mar 1, 2020 at 13:21
  • Okay, then in that case, you'll need to use the git fast-export technique. That will rewrite your history, but you'll need to do that to fix it.
    – bk2204
    Mar 1, 2020 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.