关于git:git-代理

2次阅读

共计 883 个字符,预计需要花费 3 分钟才能阅读完成。

执行 git config - l 查看代理

勾销 http 代理, 勾销 https 代理

# 勾销 http 代理
git config --global --unset http.proxy
#勾销 https 代理
git config --global --unset https.proxy

HTTP 代理

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

Socks5 代理

git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

留神这里的 socks5 仅仅是代理应用的协定,它仍然是针对 http 设置的,所以仅对 http 协定的仓库无效。应用 git@xxx 这种 ssh 连贯的不会应用代理。

也能够分域名设置代理:

git config --global http.https://github.com.proxy http://127.0.0.1:1080
git config --global https.https://github.com.proxy https://127.0.0.1:1080

SSH 代理

SSH 代理须要在密钥目录 (~/.ssh) (Windows 下是 C:\Users{UserName}.ssh) 新建一个 config 文件,没有后缀名。

Linux 零碎写入以下配置(未验证):

 须要 netcat
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p

Windows:

 -S 为 socks, -H 为 HTTP
ProxyCommand connect -S 127.0.0.1:1080 %h %p

如果找不到 connect 命令那么指定其绝对路径,个别在 git 装置目录下 \mingw64\bin\connect.exe.

也能够分域名代理:

Host github.com
    ProxyCommand connect -S 127.0.0.1:1080 %h %p
正文完
 0