Since git 2.22, you can use git submodule set-branch
for that:
git submodule set-branch --branch mybranch public
This adds a branch = mybranch
to your .gitmodules
. Which you may also add manually, if you'd rather do so.
More information can be found on git-submodule(1).
You may also want to take a look at this answer, which elaborates more on what exactly it means to track a branch. Most importantly:
git submodule add -b is not some magically way to keep everything up to date with a branch. It is simply adds information about a branch in the .gitmodules file and gives you the option to update the submodule object to the latest commit of a specified branch before populating it.