'Bitbucket submodule update periodically fails but clone doesn't

After cloning a repo in Bitbucket that has submodules, once in a few weeks, following happens for several minutes to several hours:

One of the repositories that is a submodule fails to clone with git submodule update --init --jobs 16 --force. When that happens, it's only one out of all the submodules and it's that same repository until the problem goes away. Next time it will be a different one. When that happens, repository clones work fine with git clone - just the submodule way of cloning that fails.

Number of jobs doesn't matter. --jobs=1 works in the same way. Git version doesn't matter (tried several different ones). Bitbucket access log isn't helpful. Entries are same pretty much for both success and failure in atlassian-bitbucket-access.log. The URL in .gitmodules is correct and no proxy server is being used.

Bitbucket version is 5.16.5

The git error: fatal: the remote end hung up unexpectedly The log entry in Bitbucket access log:

10.128.146.44 | ssh | i@WMYO89x939x37670172x5 | username | 2022-05-12 15:39:00,596 | SSH - git-upload-pack '/project/repo.git' | "SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8" | - | - | - | - | - | 1fdp8p1 | 
10.128.146.44 | ssh | o@WMYO89x939x37670172x5 | username | 2022-05-12 15:39:00,629 | SSH - git-upload-pack '/project/repo.git' | "SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8" | 0 | 1269 | 438198 | cache:hit, clone, protocol:1, ssh:user:id:951 | 33 | 1fdp8p1 | 

While trying out the https cloning, following error comes up:

fatal: remote error: upload-pack: not our ref <a git hash here that points to a commit abject>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source