使用子模块克隆仓库:覆盖凭证 [英] Clone a repo with submodules: override credentials

查看:75
本文介绍了使用子模块克隆仓库:覆盖凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须自动化克隆存储库并获取所有子模块.存储库子模块的url在 .gitmodules 中指定.如果我要使用默认值,我会这样做

I have to automate cloning a repository and fetching it's all submodules. The urls for repository submodules are specified at .gitmodules. If I were to go with defaults I would just do

git clone --recursive https://username:password@url.git

问题是凭据没有包含在 .gitmodules 文件中,克隆时会提示我输入凭据.我必须使用HTTPS而不是SSH.

The problem is credentials aren't included in .gitmodules file and I am prompted for those when I clone. I have to use HTTPS rather then SSH.

我尝试使用git config提交凭据:

I tried to submit the credentials using git config:

git clone https://username:password@url.git my_repo
cd my_repo
git submodule init
git config submodule.my_submodule.url "https://username:password@url/my_submodule.git"
git submodule update

,但在最后更新步骤中提示输入凭据.我检查了子模块的URL是否正确,并且在 .git/config 文件中具有正确的凭据.

but I get prompted for credentials in the last update step. I've checked that the submodule url is correct and has proper credentials in .git/config file.

推荐答案

在编辑 .gitmodules 文件后,您需要使用

After editting the .gitmodules file you need to apply changes using

git submodule sync

下次运行 git子模块更新时,将使用新的URL.

The next time you run git submodule update the new url will be used.

这篇关于使用子模块克隆仓库:覆盖凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆