Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to clone repository with submodules

Francisco Perez Moreno November 8, 2022

I have a repo with submodules. I need to access it via https.

The .gitmodules file has this format:

[submodule "submodules/sm1"]
path = submodules/sm1
url =

So if I git submodule update --init, it asks me for a user name (which disallows this from being a non-interactive session, which is pointless)

If I put the user within the url (as mentioned in, then I can use GIT_ASKPASS to do a git clone in a scriptable way.

But I don't want to use to put a specific and concrete user within the url in a submodule.

Is there a way to keep the .gitmodules file clean without any ad-hoc username, so I can share a repo between several developers; and also, clone it with its submodules in a scriptable way? None of the previous messages work, they always end up in git complaining about not having access rights.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2022

Hi Francisco,

Is it a requirement to use HTTPS?

If so, please let me know, I'll need some time to look into it.


In case you are ok with using SSH instead, you can use an SSH URL for the repo in the .gitmodules file

[submodule "submodules/sm1"]
path = submodules/sm1
url =

SSH URLs do not include a username and authentication is done with SSH keys. This would require users to set up SSH Bitbucket Cloud (if they haven't already), and then authentication for each user will be done with the SSH keys each user has on their own computer.

After setting up an SSH, each user can create a file named config in their ~/.ssh folder with the following configuration, to ensure that the SSH key they generated is used when they connect to

User git
IdentityFile /Users/myUser/.ssh/id_rsa
IdentitiesOnly yes

where /Users/myUser/.ssh/id_rsa is the path to the private SSH key in the user's computer.


If you're using a script, you would need to have an SSH key pair on the machine where the script is running. If the script is used to only clone/pull, you could set up Access keys:

Otherwise, you would need the SSH keys of a user with access to the repo.


If you have any questions, please feel free to let me know.

Just a heads up, I moved your post to a new question. It's best to create a separate question if you need assistance with something, as a new question will have visibility to the rest of my team if I'm out of office, and also because a certain question can become difficult to follow if we try to troubleshoot multiple users' issues.


Kind regards,

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events