title: How to change git submodules url locally?
body: <p>The original <code>.gitmodules</code> file uses the hard coded <code>https</code> urls but for some automated tests I clone from <code>ssh</code> and make the submodule urls relative as in <code>../ModuleName</code>. I don't want to push these changes back into the repo either.</p>
  
  <pre><code># change the https://github.com/ with git@github.com:
  sed -i 's/https:\/\/github.com\//git@github.com:/g' ".git/config"
  # delete the url lines from the submodule blocks of .git/config
  sed -i '/submodule/ {$!N;d;}' ".git/config"
  # change hardcoded https:// urls of submodules to relative ones
  sed -i 's/https:\/\/github.com\/ProjName/../g' ".gitmodules"
  # also make the same change in the .git/modules/*/config
  sed -i 's/https:\/\/github.com\/ProjName/../g' .git/modules/*/config
  # sync and update
  git submodule sync
  git submodule update --init --recursive --remote
  </code></pre>
  
  <p>With the snippet above, it does what I want. However, the annoying thing is, <code>.git/modules/</code> folder doesn't seem to be under version control but if I just delete it, <code>git submodule sync</code> and most other Git operations just stop working.</p>
  
  <p>Is there a way to get the <code>.git/modules</code> regenerated after modifying the <code>.gitmodules</code> and <code>.git/config</code> files?</p>