Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

change git submodule clone url from ssh to https

I have a git repo for which someone has already added the submodule and it seems they have made this submodule as git url rather than https url so as of now the submodule update tries to clone it ssh based git url.

I am trying to change now this submodule clone type to https based url and have modified the .gitmodules file where I have put the correct https url however the cloning or updating the submodule using command git submodule update --init --recursive still uses the ssh based url. Upon further examination it is observed that config file in .git folder of the main repo still has ssh url and I am not sure what process I should follow further to update locally as well as push the change to main repo for everyone else.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

After initial git clone --recursive or git submodule update --init --recursive URLs from .gitmodules copied to .git/config and changes in .gitmodules don’t affect .git/config. You need to update URLs in .git/config using this command:

git submodule sync --recursive

See the docs.

If you want to fix just one URL it could as simple as

cd <submodule_path>
git config submodule.<submodule_name>.url <new_URL>
cd <../back/to/the/superproject>

<submodule_path>, <submodule_name>, <new_URL>, <../back/to/the/superproject> are placeholders here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading