terminal, git代理设置

因为某些众所周知的原因,需要设置代理访问某些网址。终端的设置和git的设置稍有不同。

1. Mac代理设置

打开.bash_profile文件

vi .bash_profile

将如下内容复制到文件末尾:

function proxy_off(){
    
    
        unset http_proxy
        unset https_proxy
        unset ftp_proxy
        unset rsync_proxy
        echo -e "已关闭代理"
        curl cip.cc
}
 
function proxy_on() {
    
    
        export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
        export http_proxy="http://127.0.0.1:19180"
        export https_proxy=$http_proxy
        export ftp_proxy=$http_proxy
        export rsync_proxy=$http_proxy
        export HTTP_PROXY=$http_proxy
        export HTTPS_PROXY=$http_proxy
        export FTP_PROXY=$http_proxy
        export RSYNC_PROXY=$http_proxy
        echo -e "已开启代理"
        curl cip.cc
}

其中,19180是代理端口。然后配置生效

source .bash_profile

开启代理

AdministratordeMacBook-Air:ios administrator$ proxy_on
已开启代理
IP	: 172.104.78.245
地址	: 日本  东京都  品川区
运营商	: linode.com

数据二	: 日本东京都品川区 | Linode

数据三	: 日本东京都东京

URL	: http://www.cip.cc/172.104.78.245
AdministratordeMacBook-Air:ios administrator$ 

关闭代理命令:proxy_off

2. git代理设置

git设置代理就比较简单了:

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

其中,19180为代理端口。

取消代理如下:

git config --global --unset http.proxy
git config --global --unset https.proxy

猜你喜欢

转载自blog.csdn.net/weixin_29003023/article/details/125126334
今日推荐