linux下解决git clone太慢

此教程同样也适用与vscode下载太慢的问题

git和vscode会自动使用http_proxy,https_proxy环境变量的代理,所以我们只需要设置这个环境变量即可

前提

需要一个可用的代理,这里我以socks5为例,具体怎么获取请自行解决。

设置环境变量

linux下设置环境变量的命令为

export 变量名=变量值

linux下删除环境变量的命令为

unset 变量名

linux下给一个命令其别名

alias 别名='命令 参数'

综上,为方便起见我们将给http_proxy,https_proxy赋值的过程取名为setproxy,取消http_proxy,https_proxy的过程取名为unsetproxy

为使每次打开终端均生效我们可以将其写入.zshrc文件(如果你用的是bash就写入.bashrc文件),在文件中加入以下两行

alias setproxy='export http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080'
alias unsetproxy='unset http_proxy https_proxy'

最后别忘了使文件生效

source ~/.zshrc
原文地址:https://www.cnblogs.com/kainhuck/p/12374940.html