直接執行命令是只對當前終端進行代理,不影響環境,如果要設置永久代理,需要寫入~/.bashrc文件中
#cmd
set http_proxy=http://127.0.0.1:1080
set https_proxy=http://127.0.0.1:1080
或者
set ALL_PROXY=http://127.0.0.1:1080
#git bash,git bash可以通過在~路徑下新建.bashrc,將下面兩條命令寫入,然后source ~/.bashrc,就可以實現永久的設置代理
export http_proxy=http://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080
或者
export ALL_PROXY=http://127.0.0.1:1080
或者直接使用alias來簡介操作,每次要用的時候輸入setproxy,不用了就unsetproxy。
alias setproxy="export ALL_PROXY=http://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY"
#用這條命令來驗證,不能使用ping(ping的協議不是https,也不是https,是ICMP協議)
curl -vv http://www.google.com
如果指向對某些命令進行代理,也可以改相應工具的配置,比如apt的配置
sudo vim /etc/apt/apt.conf
在文件末尾加入下面這行
Acquire::http::Proxy "http://proxyAddress:port"
重點來了!!如果說經常使用git對於其他方面都不是經常使用,可以直接配置git的命令。
使用ss/ssr來加快git的速度
直接輸入這個命令就好了
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'