Automatically access git submodules via ssh or https
<p><strong>Question:</strong><br>
Is there a way to automatically checkout git submodules via the same method (ssh or https) as the main repository?</p>

<p><strong>Background:</strong></p>

<p>We have a non-public gitlab repository (<code>main</code>) that has a submodule (<code>utils</code>) which is also hosted as a non-public gitlab repository on the same server. Those repositories can be accessed either via ssh or https:</p>

<ul>
<li><code>user@gitlabserver.com:my/path/repo.git</code></li>
<li><code>https://gitlabserver.com/my/path/repo.git</code></li>
</ul>

<p>Both variants obviously require different forms of authentication and depending on the client computer and the user, one or the other is preferred. </p>

<p>For the top level repository (<code>main</code>) that is not an issue, as anyone can choose the method he or she prefers, but for the sub module this depends on the <code>.gitmodules</code> file and hence is (initially) the same for all.<br>
Now instead of everyone having to adapt the .gitmodules file to whatever they prefer and make sure they don't accidentally commit those changes, it would be nice, if there was a way to just specify the server and repo path and git chooses either the same method that is used for the main repo, or something that can be set in gitconfig.</p>