如何克隆 git 带有子模块的存储库而不要求每个子存储库的密码
how to clone git repository with submodules without asking for password for every subrepository
我最近将一个存储库放入了 bitbucket。这个存储库有一些子模块
我正在编写初始化脚本。我想克隆主目录,然后他们拉取所有子目录。
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
我如何克隆主存储库并且它们对所有子存储库使用相同的凭据?
我正在使用 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
这足以拉取具有相同 user/password
的所有回购协议
如果我想在一整天内保留相同的缓存,我可以将时间设置为更长的时间跨度:
git config --global credential.helper 'cache --timeout=86400'
86400 秒 = 1 天;
我最近将一个存储库放入了 bitbucket。这个存储库有一些子模块
我正在编写初始化脚本。我想克隆主目录,然后他们拉取所有子目录。
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
我如何克隆主存储库并且它们对所有子存储库使用相同的凭据?
我正在使用 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
这足以拉取具有相同 user/password
的所有回购协议如果我想在一整天内保留相同的缓存,我可以将时间设置为更长的时间跨度:
git config --global credential.helper 'cache --timeout=86400'
86400 秒 = 1 天;