Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use git submodule init property?

I have a submodule in my git (private repository, located in bitbucket as well) and I want to load it in the pipelines but I get the error:

fatal: could not read Username for '': No such device or address

Now, obviously, the error occurs because I didn't set user and password and my question is how can I do it properly assuming that we use with our submodules



1 answer

1 accepted

1 vote
Answer accepted

Hi @Aharono,

If you want to use HTTPS, you can create and use repository variables for the username and password. I strongly recommend generating an app password for your Bitbucket account with permissions "Repositories : Read" only, and use that app password instead of your account's password.

After you generate the app password, open in Bitbucket website the repo that has the submodule. Select Repository settings > Repository variables and create one variable for your Bitbucket username and another one for the app password.

Please make sure that the variable for the app password is marked as Secured, so that its value won't appear in the Pipelines log. You can also make the username variable Secured if you don't want your username to be visible in the Pipelines log.

Let's say the variables are named BB_username and BB_password. Then, in your bitbucket-pipelines.yml file you can add the following commands:

- git config submodule.<my-submodule>.url https://${BB_username}:${BB_password}<workspace-id>/<submodule-repo>.git
- git submodule init
- git submodule update

<my-submodule> replace with the name of the submodule, as defined in the .gitmodules file
<workspace-id> replace with the workspace id that owns the submodule
<submodule-repo> replace with the repo slug for the submodule repo


Please keep in mind though that even secured variables can be retrieved by all users with write access to a repository. If other users have write access to these two repos and you'd like to avoid that, another option would be to use SSH instead of HTTPS.

In order to set this up, open in Bitbucket website the repo that has the submodule. Select Repository settings > SSH keys and then select Generate keys to generate an SSH key pair for Pipelines in this repo. Then, copy the public key.

Open the submodule repository on Bitbucket website, go to its Repository settings > Access keys and add there the public SSH key you copied before.

Afterwards, you can use the following commands in your yml file:

- git config submodule.<my-submodule>.url<workspace-id>/<submodule-repo>.git
- git submodule init
- git submodule update

Make the same replacements in the 'git config' command as I mentioned earlier.

Please feel free to let me know if this works for you and if you have any questions.

Kind regards,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,516 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you