While pulling submodule repositories in CI servers like Jenkins/CircleCI, repositories with HTTPS submodule url will ask for credentials, which is hard for automation.

Demo of .gitmodules

$ cat .gitmodules
[submodule "common"]
    path = common
    url = https://github.com/dhoeric/common.git

After you trying to pull submodule repo, you will be asked for password…

$ git submodule sync
$ git submodule update --init
Submodule 'common' (https://github.com/dhoeric/common.git) registered for path 'common'
Cloning into '~/r/hello-submodule/common'...
Username for 'https://github.com':

To change all HTTPS url into SSH, run the following command

perl -i -p -e 's|https://(.*?)/|git@\1:|g' .gitmodules

The output of .gitmodules

$ cat .gitmodules
[submodule "common"]
    path = common
    url = git@github.com:dhoeric/common.git