I googled this error and found various answers, some fairly complicated.
However I think I know why this happened to me, I changed the remote url of a submodule, from https to ssh.
The remote url of the submodule, and the url in .gitmodules match, so that’s not an issue.
I’ve attempted deinit the submodule and readding it, and it hasn’t worked.