I need to use ssh forwarding-agent to enable git cloning on remote servers. The repository has submodules which were originally added with their https addresses. In
Use git config --global url.<base>.insteadOf to substitute URLs on the fly. Something like
git config --global url.<new-url-with-https>.insteadOf git@<server>:<user>/<repo>.git
See more examples in https://stackoverflow.com/search?q=%5Bgit-submodules%5D+insteadof
The URL of the module is stored in .gitmodules at the root of your sandbox. This file is tracked as part of the Git repository. If you make the change here and commit it, it will be visible to other users of the Git repo.
When you call git submodule sync and then git submodule init, the URL is resolved and copied to .git/config. When you call git submodule update, the submodule is cloned and its URL is also found in .git/modules/<module-name>/config.
To permanently change the URL, edit .gitmodules and call git submodule sync and git submodule init again.
To temporarily change the URL, make these two changes instead:
Change the URL in .git/config for the submodule
Go inside the submodule and call:
git remote set-url origin <new-url-with-https>
The second command will update the URL in .git/modules/<module-name>/config which is the .git folder for the submodule.