You can edit .gitmodules manually (using an editor) or using git config -f .gitmodules. After modifying sync it to .git/config with the command git submodule sync and update submodules using git submodule update --init --remote.
from: https://stackoverflow.com/questions/58012887/how-to-switch-git-submodule-with-other-branch-properly