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

2

6

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.

Quintana answered 8/8, 2018 at 20:23 Comment(2)
aren't you using SSH directly for this? Check help.github.com/articles/…Barnsley
See Caching your GitHub password in Git. It's not specific to Github.Hearst
Q
11

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;

Quintana answered 9/8, 2018 at 20:25 Comment(0)
T
0

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.

Trippet answered 9/8, 2018 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.