如何使用子模块克隆git存储库,而无需为每个子存储库请求密码
我最近将一个存储库放入bitbucket。这个存储库有一些子模块 我正在编写一个初始化脚本。我想克隆主目录,并将其拉入所有子目录如何使用子模块克隆git存储库,而无需为每个子存储库请求密码,git,git-submodules,Git,Git Submodules,我最近将一个存储库放入bitbucket。这个存储库有一些子模块 我正在编写一个初始化脚本。我想克隆主目录,并将其拉入所有子目录 git clone https://bitbucket.org/#####/main.git elastic --recurse-submodules 这会提示我输入用户和密码 Username for 'https://bitbucket.org': myuser Password for 'https://myuser@bitbucket.org': 然
git clone https://bitbucket.org/#####/main.git elastic --recurse-submodules
这会提示我输入用户和密码
Username for 'https://bitbucket.org': myuser
Password for 'https://myuser@bitbucket.org':
然后它又问我每个子模块
Username for 'https://bitbucket.org':
...
我的.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
我如何克隆主存储库,并且它们对所有Child存储库使用相同的凭据
我正在使用AWS AMI Linux。检查您的git配置输出: 类型:
git config-l
如果您看到如下规则:
git config --global url.https://github.com/.insteadOf git@github.com/
这将解释为什么HTTPS URL的凭据甚至用于子模块。设置git以使用凭据内存缓存解决了我的问题
git config --global credential.helper cache
这足以拉取具有相同用户/密码的所有回购协议
如果我想将同一缓存保留一整天,我可以将时间设置为更长的时间跨度:
git config --global credential.helper 'cache --timeout=86400'
86400秒=1天 您不是直接使用SSH来实现这一点吗?看看。这不是Github特有的,很好+1.救了我的命!!