如何为git子模块使用相同的协议? [英] How to use same protocol for git submodules?

查看:66
本文介绍了如何为git子模块使用相同的协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git存储库R中,我有一个子模块,该子模块使用以下命令初始化:

In a git repository R I have a submodule that I initialized with the following command:

git submodule add git@mygitserver...

现在,用户刚刚使用https克隆了R并在运行时出现错误

Now a user just cloned R using https and get an error when running

git submodule init
git submodule update

因为他没有ssh(在服务器上上传了公共密钥)访问权限. 所以我的问题是,是否有可能创建一个子模块,该子模块将自动使用与用于克隆git submodule update命令上的父存储库的协议相同的协议?

because he doesn't have ssh (with public key uploaded on the server) access. So my question is, is it possible to create a submodule that will automatically uses the same protocol than the one used to clone the parent repository on the git submodule update command ?

推荐答案

该用户可以设置配置:

git config --global url.https://mygitserver/.insteadOf ssh://git@mygitserver/
# or possibly (to be tested)
git config --global url.https://mygitserver/.insteadOf git@mygitserver/

那样,https url将始终用于mygitserver(主存储库或子模块),而不是ssh.

That way, https urls will always be used for mygitserver (main repo or submodules), instead of ssh ones.

这篇关于如何为git子模块使用相同的协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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