GIT与GFW

admin 2022年11月24日21:27:45评论69 views字数 790阅读2分38秒阅读模式

11.24 GIT与GFW

http://scz.617.cn:8/unix/202211231303.txt

Q:

有时可能需要

git clone --recursive git@…

但.gitmodules中是这样的

[submodule "subm1"]
   path = subm1
   url = https://…
[submodule "subm2"]
   path = subm2
   url = https://…

于是递归中出现

git clone https://…

众所周知,寡妇王对HTTPS并不友好,挂线路自然是可以的,但我想问的是,假设可以手工修改拖回本地的.gitmodules,有无正经办法让递归时不用HTTPS。现在只能clone完主模块后,手工clone每个子模块,将https换成git;倒也可行,只是太low。

A: 2022-11-23

网友「李同学virusdefender」(3560808645)指出,可以用insteadOf配置。实测如下用法满足原始需求

cd /tmp
git config --global [email protected]:.insteadOf https://github.com/
git config -l
git clone --recursive https://github.com/libbpf/libbpf-bootstrap.git libbpf-bootstrap
git config --global --unset [email protected]:.insteadOf
git config -l

"git config -l"无必要,只是为了观察配置。"--unset"无必要,只是出于洁癖,我不喜欢改.gitconfig文件。配置生效期间,所有"https://"被自动替换成"git@…"。

原文始发于微信公众号(青衣十三楼飞花堂):GIT与GFW

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年11月24日21:27:45
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   GIT与GFWhttp://cn-sec.com/archives/1425509.html

发表评论

匿名网友 填写信息