我必须automate克隆存储库并获取它的所有子模块。存储库子模块的 url 指定于.gitmodules
。如果我要使用默认值,我就会这样做
git clone --recursive https://username:[email protected] /cdn-cgi/l/email-protection
问题是凭据不包含在.gitmodules
文件,当我克隆时,系统会提示我输入这些内容。我必须使用 HTTPS 而不是 SSH。
我尝试使用 git config 提交凭据:
git clone https://username:[email protected] /cdn-cgi/l/email-protection 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
file.
看起来您正在尝试使用 git 凭据,但运气不佳。
Option 1
使用凭证助手添加凭证:
git config credential.https://example.com.username myusername
git config credential.helper "$helper $options"
检查你的〜/.gitconfig并验证是否添加了适当的条目。
进一步阅读:http://git-scm.com/docs/gitcredentials http://git-scm.com/docs/gitcredentials
Option 2
我会仔细检查 .git-credentials 文件的内容,并为子模块创建一个新条目(如果不存在)。该文件由 git 凭证助手在内部使用。
http://git-scm.com/docs/git-credential-store http://git-scm.com/docs/git-credential-store
Option 3
Windows 中的简单解决方案是从模块文件中删除用户名、密码:
[submodule foo]
path = sub/foo
url = https://example.com/git/foo.git
并创建一个 ~/.netrc 文件。
machine example.com
login myusername
password areamandyingtotellsomeonehiscoolpassword
感谢Git 子模块 URL 不包含用户名? https://stackoverflow.com/questions/7714326/git-submodule-url-not-including-username.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)