如何在不要求每个子存储库的密码的情况下使用子模块克隆 git 存储库

Dan*_*tos 3 git git-submodules

我最近将一个存储库放入 bitbucket。这个存储库有一些子模块

我正在处理初始化脚本。我想克隆主目录并拉取所有子目录。

 git clone https://bitbucket.org/#####/main.git elastic --recurse-submodules
Run Code Online (Sandbox Code Playgroud)

这提示我输入用户名和密码。

Username for 'https://bitbucket.org': myuser 
Password for 'https://myuser@bitbucket.org': 
Run Code Online (Sandbox Code Playgroud)

他们再次询问我每个子模块

Username for 'https://bitbucket.org':  
...
Run Code Online (Sandbox Code Playgroud)

我的 .gitmodules 文件是这样的:

[submodule "api"]
     path = app/api/
     url = git@bitbucket.org/###/api.git
     branch = master
[submodule "front"]
     path = app/front
     url = git@bitbucket.org/###/front.git
     branch = master
[submodule "app/config"]
     path = app/config
     url = git@bitbucket.org/###/config.git
     branch = master

... some few more repositories
Run Code Online (Sandbox Code Playgroud)

如何克隆主存储库,并且它们对所有子存储库使用相同的凭据?

我正在使用 AWS AMI Linux。

Dan*_*tos 10

设置 git 以使用凭证内存缓存解决了我的问题

git config --global credential.helper cache
Run Code Online (Sandbox Code Playgroud)

这足以使用相同的用户/密码提取所有存储库

如果我想在一整天内保持相同的缓存,我可以将时间设置为更长的时间跨度:

git config --global credential.helper 'cache --timeout=86400'
Run Code Online (Sandbox Code Playgroud)

86400 秒 = 1 天;