[英]git - Can you clone via HTTPS even if SSH-style git@github is used
I'm trying to clone a git repository which has submodules via git submodule update --init --recursive
.我正在尝试通过
git submodule update --init --recursive
克隆具有子模块的 git 存储库。 These submodules all use "git@github.com:foo/bar.git" URLs.这些子模块都使用“git@github.com:foo/bar.git” URL。 Unfortunately, my work place is preventing SSH URLs from their firewall.
不幸的是,我的工作场所正在阻止 SSH URL 从他们的防火墙中访问。 I can, however, clone via HTTPS, with no problems.
但是,我可以通过 HTTPS 克隆,没有任何问题。
As mentioned, the submodule URLs are hard-coded in the repository to use SSH.如前所述,子模块 URL 在存储库中被硬编码为使用 SSH。 Is there a way to tell git to clone these submodule repositories using HTTPS without instead of SSH making any direct modifications to the git repository?
Is there a way to tell git to clone these submodule repositories using HTTPS without instead of SSH making any direct modifications to the git repository?
Use git config --global url.<base>.insteadOf
to substitute URLs on the fly.使用
git config --global url.<base>.insteadOf
替换 URL。 Something like就像是
git config --global url.https://github.com/.insteadOf git@github.com:
(Please note the colon at the end; it's neccessary to map git@github.com:user/repo.git
to https://github.com/user/repo.git
). (Please note the colon at the end; it's neccessary to map
git@github.com:user/repo.git
to https://github.com/user/repo.git
).
See more examples in https://stackoverflow.com/search?q=%5Bgit-submodules%5D+insteadof在https://stackoverflow.com/search?q=%5Bgit-submodules%5D+insteadof中查看更多示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.