当前位置:   article > 正文

git 加速代理设置,单仓库设置代理,指定仓库设置单独代理_git加速

git加速

1. git全局设置代理

git config --global https.proxy http://127.0.0.1:7890

git config --global https.proxy https://127.0.0.1:7890
  • 1
  • 2
  • 3

取消的命令:

git config --global --unset http.proxy

git config --global --unset https.proxy
  • 1
  • 2
  • 3

相信这种方法大多人都使用过,当使用github的时候,需要开代理,但是使用国内的git仓库或者自建的git仓库的时候,代理反而成了累赘。这里可能就需要用到单仓库加速了。

2. 单仓库加速

有时候我们对 github 的仓库进行 clone 的时候,会发现很慢,甚至是龟速,很不够效率。好在有一个简单且快捷的方法来倍速提升clone 效率。

我们通过检索 git 的帮助文档发现有这样的描述

If you just want to use proxy on a specified repository, don’t need on other repositories. The preferable way is the -c, —config <key=value> option when you git clone a repository. e.g.

实践起来
git clone https://github.com/flutter/flutter.git --config "http.proxy=192.168.0.105:7890"
  • 1

上面的例子

  • 通过 --config "http.proxy=192.168.0.105:7890" 设置代理
  • 其中 192.168.0.105:7890 是代理的地址,需要自己搭建或者可用的,我这里是使用clash的局域网本地代理。

上面的配置好,再次执行,基本上可以得到百倍的提效。

部分转载自技术小黑屋:https://droidyue.com/blog/2022/10/26/speed-up-git-clone-via-proxy/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/406851
推荐阅读
相关标签
  

闽ICP备14008679号