Forks cannot be synchronized in Bitbucket Datacenter due to "refs does not point to a valid object" error

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

During the automatic fork synchronization, the following appears in the atlassian-bitbucket.log:

1 2 3 4 5 WARN [ref-sync:thread-1] c.a.s.i.r.s.a.AutoRefSyncProcessor <fork project>/<fork repository>[<fork repository_id>]: Could not synchronize changes with <source project>/<source repository>[<source repository_id>] com.atlassian.bitbucket.scm.CommandFailedException: '/usr/bin/git -c gc.auto=0 fetch --no-tags ../<source repository_id> refs/heads/feature/branch1:refs/heads/feature/branch1' exited with code 0 saying: error: refs/heads/feature/invalid_branch1 does not point to a valid object! error: refs/heads/feature/invalid_branch1 does not point to a valid object! error: refs/heads/feature/invalid_branch2 does not point to a valid object! error: refs/heads/feature/invalid_branch3 does not point to a valid object!

Diagnosis

Diagnostic Steps

Run "git fsck" command on the repository. The utility will report a "invalid sha1 pointer" error for each line mentioned above.

Cause

A git gc has been run on the source repository, which removed the references to the branches just from the source repository.

⚠️ Never run git gc directly on a repository, here are more details on why that's the case: How to perform manual garbage collection on a repository in Bitbucket Server.

Solution

Resolution

Delete the forked repository and create the fork again.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.