Git fetch is not fetching all branches. error: pathspec did not match any file(s) known to git.

The problem can be seen when checking the remote.origin.fetch setting
(The lines starting with $ are bash prompts with the commands I typed. The other lines are the resulting output)
$ git config --get remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master
As you can see, in my case, the remote was set to fetch the master branch specifically and only. I fixed it as per below, including the second command to check the results.
$ git config --replace-all remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
$ git config --get remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*
The wildcard * of course means everything under that path.