Pushing to Bitbucket Server reports there are too many unreachable loose objects

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

When pushing to Bitbucket Server, the following message is written in Command Prompt / Terminal:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $ git push -f Counting objects: 10, done. Delta compression using up to 8 threads. Compressing objects: 100% (10/10), done. Writing objects: 100% (10/10), 838 bytes | 0 bytes/s, done. Total 10 (delta 7), reused 0 (delta 0) remote: remote: View pull request for package-generation => develop: remote: https://mybitbucketinstance/projects/PROJ/repos/my-repo/pull-requests/261 remote: error: The last gc run reported the following. Please correct the root cause and remove 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. To ssh://git@mybitbucketinstance/proj/my-repo.git + 71f8fbd...954cbcb package-generation -> package-generation (forced update)

Diagnosis

  • The error is prefixed by "remote" indicating that the error was generated by the remote (i.e., by Bitbucket Server).

  • Running git prune (as suggested in the error message) does not help.

Cause

Garbage collection is being triggered when the client attempts to push to the server and this is failing due to the existence of the gc.log file; daemonized git gc now saves output to gc.log. Hence, subsequent executions of gc --auto will not run.

The push does succeed and does not prevent developers from working as normal.

Solution

Workaround

  1. Determine the ID of the repository into which changes are being pushed

  2. Go to <BITBUCKET_HOME>/shared/data/repositories/<repository_id>

  3. Delete the gc.log file.

  4. Run git config --bool gc.autodetach false

Resolution

Upgrade to Bitbucket Server 5.0+ which provides enhancements to how Bitbucket Server handles garbage collection internally.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.