Forks cannot be synchronized in Bitbucket Datacenter due to "refs does not point to a valid object" error
Platform Notice: Data Center - This article 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.
*Fisheye および Crucible は除く
問題
During the automatic fork synchronization, the following appears in the atlassian-bitbucket.log:
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!
診断
Diagnostic Steps
Run "git fsck"
command on the repository. The utility will report a "invalid sha1 pointer"
error for each line mentioned above.
原因
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.
ソリューション
Delete the forked repository and create the fork again.