Daniel Santos
Daniel Santos

Reputation: 15918

how to clone git repository with submodules without asking for password for every subrepository

I'm recently put a repository into bitbucket. And this repository has some submodules

I'm working on a Initialization script. I would like to clone the main directory and them pull all subdirectories.

 git clone https://bitbucket.org/#####/main.git elastic --recurse-submodules

this prompts me for the user and password.

Username for 'https://bitbucket.org': myuser 
Password for 'https://[email protected]': 

and them it asks me again for every submodule

Username for 'https://bitbucket.org':  
...

My .gitmodules file is like:

[submodule "api"]
     path = app/api/
     url = [email protected]/###/api.git
     branch = master
[submodule "front"]
     path = app/front
     url = [email protected]/###/front.git
     branch = master
[submodule "app/config"]
     path = app/config
     url = [email protected]/###/config.git
     branch = master

... some few more repositories

How can I clone the main repository and them use the same credentials to all childs repositories?

I'm using AWS AMI Linux.

Upvotes: 6

Views: 5221

Answers (2)

Daniel Santos
Daniel Santos

Reputation: 15918

Setting up the git to use the credential memory cache solves my problem

git config --global credential.helper cache

this is enough to pull all repos with the same user/password

If i want to keep the same cache for a entire day, I'm able to set the time for a longer timespan:

git config --global credential.helper 'cache --timeout=86400'

86400 seconds = 1 day;

Upvotes: 11

VonC
VonC

Reputation: 1326784

Check your git config output:

type: git config -l

If you see a rule like:

git config --global url.https://github.com/.insteadOf [email protected]/

That would explain why credentials for an HTTPS URL are used even for submodules.

Upvotes: 0

Related Questions