Git clone 太慢了解一下 Mac Linux 设置代理和取消代理的方法
设置代理
$ export http_proxy=http://127.0.0.1:49776
$ export https_proxy=$http_proxy
$ export ftp_proxy=$http_proxy
$ export rsync_proxy=$http_proxy
$ export no_proxy="localhost,127.0.0.1"
查看当前代理
$ echo $http_proxy
$ echo $https_proxy
取消代理
$ unset http_proxy
$ unset https_proxy
$ unset ftp_proxy
$ unset rsync_proxy
Mac 查看代理端口号
一般情况代理端口号是在 System Preferences -> Network -> Advanced -> Proxies 中查看,如图:
有人用的端口可以能是 1086,查看端口有没有在使用,可以用命令:
$ lsof -i:1080
$ lsof -i:1086
git 是支持代理的,git 设置全局代理:
$ git config --global --list
$ git config --global https.proxy 'socks5h://127.0.0.1:1080'
$ git config --global http.proxy 'socks5h://127.0.0.1:1080'
git 取消代理:
$ git config --global --unset https.proxy
$ git config --global --unset http.proxy
补充
全局代理设置命令比较烦,可以集成到一个 shell 环境变量里,我这里用的 shell 是 zsh,若以修改 zsh 配置文件:
$ subl ~/.zshrc
~/.zshrc
:
# proxy list
alias proxy='export all_proxy=socks5://127.0.0.1:1080'
alias unproxy='unset all_proxy'
本作品采用《CC 协议》,转载必须注明作者和本文链接
本帖由 Galois
于 4年前 加精
推荐文章: