Changing a branch caused git to "refs/heads/ refs/tags/' exited with code 128 saying: fatal missing object"
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
Symptoms
The following symptom appears when editing or changing a branch/tag
Error
1
'C:\Program Files (x86)\Git\bin\git.exe for-each-ref --sort=-objecttype --format=%(objecttype)%02%(refname)%02%(refname:short)%02%(objectname)%02%(*objectname) refs/heads/ refs/tags/' exited with code 128 saying: fatal: missing object 0000000000000000000000000000000000000000 for refs/heads/8ad682bdd88a2c8318bc3a03e28a3479/Microsoft.Build.Framework.ni.dll
Cause
The error exist is because the causing file in .git/refs/[head|tag]/<file> exist in Bitbucket Server's filesystem but the remote ref is broken.
[heads|tag] could refer to either a branch or a tag
Resolution
To resolve this issue you would need to do the following:
Identify the repository ID for the affected branch by accessing the settings on that repository and look under "Location On Disk". The number at the end of the path would be the repository ID interested
Access Bitbucket Server's repository with that ID which can be found here
<Bitbucket Server_Home>/shared/data/repositories/<repository-ID>
Continue navigating though the directory
refs/[heads|tag]/<name>
where the error complains about the missingobject
Check for the presence of the file the error was interested with. (As an example to the above error, the file that we are interested would be
Microsoft.Build.Framework.ni.dll
)Remove that file
Note that by removing this file, you will be removing that branch/tag from Bitbucket Server. You can recreate the branch/tag again by pushing back a local content back to Bitbucket Server
If present, locate the same line ( refs/[heads|tag]/<name> ) in the file
/data/repositories/<repository-id>/packed-refs
and remove only that line.Restart Bitbucket Server instance
Was this helpful?