简体   繁体   English

强制 git 使用 https 协议克隆子模块

[英]Force git to clone submodules using https protocol

I have a git project with a submodule as a dependency which in turn has others submodules dependencies.我有一个带有子模块作为依赖项的 git 项目,而该子模块又具有其他子模块依赖项。

Those sub/submodules are configured to be cloned using ssh but my Jenkins must use https .这些子/子模块配置为使用ssh克隆,但我的 Jenkins 必须使用https

(Unfortunately I can't change submodules configs) (Unfortunately I can't change Jenkins) (不幸的是我无法更改子模块配置)(不幸的是我无法更改 Jenkins)

Is there any way to tell git to clone submodules (and their submodules) using https only?有什么方法可以告诉 git 仅使用 https 克隆子模块(及其子模块)?

Urls can be overriden by this:可以通过以下方式覆盖网址:

git config --global url."https://github.com/".insteadOf 'git@github.com:'

I am just wondering if there is a way to avoid --global but still let sub/submodules use https over git .我只是想知道是否有办法避免--global但仍然让 sub/submodules 在git使用https

I cannot comment yet and there is slight mistake in the first answer.我还不能发表评论,第一个答案有轻微错误。
Do not use ', instead use " or nothing at all.不要使用 ',而是使用 " 或根本不使用。
so the config could look something like this:所以配置可能是这样的:

git config --global url."https://github.com/".insteadOf "git@github.com:"

You can check result of your change using: config --global --list您可以使用以下config --global --list检查更改结果: config --global --list
If you use ', it will be in final config and probably won't match.如果您使用 ',它将在最终配置中并且可能不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM