[git err] warning: There are too many unreachable loose objects; run 'git prune' to remove them.



1. Problem

$ git pull

Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
warning: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.

warning: There are too many unreachable loose objects; run 'git prune' to remove them.

When i git pull repository, i see above err message and i cannot pull. This problem root cuase is There are too many dangling commits for git to automatically clean up.

  • Dangling commit
    • A commit isn’t directly linked to any child commit, branch, tag, or other references.
  • Dangling blob
    • A change that made it to the staging area/index but never got committed.

2. Solution

You can try under solutions. In my case, i solve this problem use git prune command.

2.1. git prune

$ git prune

2.2. git gc

$ git gc

2.3. git fsck

$ git fsck

reference

  • https://medium.com/lynns-dev-blog/git-there-are-too-many-unreachable-loose-objects-c2df601b8001
  • https://www.lynnbright.com/git-there-are-too-many-unreachable-loose-objects/