将git代理重置为默认配置


Reset git proxy to default configuration

我安装了Socat以通过HTTP CONNECT代理使用Git协议,然后在您的bin目录中创建了一个名为gitproxy的脚本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at https://www.emilsit.net/blog/archives/how-to-use-the-git-protocol-through-a-http-connect-proxy/

# Configuration. Common proxy ports are 3128, 8123, 8000.
_proxy=proxy.yourcompany.com
_proxyport=3128

exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport

然后我将git配置为使用它:

1
$ git config --global core.gitproxy gitproxy

现在我想将git重置为默认代理配置,我该怎么做?


对于我来说,我必须添加:

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

基本上,您可以运行:

1
git config --global -l

获取定义的所有代理的列表,然后使用" --unset"禁用它们


您可以使用以下方法删除该配置:

1
git config --global --unset core.gitproxy


在我的Linux机器上:

1
2
3
4
5
git config --system --get https.proxy (returns nothing)
git config --global --get https.proxy (returns nothing)

git config --system --get http.proxy (returns nothing)
git config --global --get http.proxy (returns nothing)

我发现我的https_proxy和http_proxy已经设置,所以我只是取消设置它们。

1
2
unset https_proxy
unset http_proxy

在我的Windows机器上:

1
2
set https_proxy=""
set http_proxy=""

(可选)使用setx在Windows上永久设置环境变量,并使用" / m"设置系统环境

1
2
setx https_proxy=""
setx http_proxy=""

编辑.gitconfig文件(可能在用户的主目录中),并将http和https代理字段更改为仅空格

1
2
3
4
[http]
    proxy =
[https]
    proxy =

在窗户上对我有用。


使用命令删除http和https设置。

git config --global --unset http.proxy

git config --global --unset https.proxy


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


如果您已使用Powershell命令在Windows计算机上设置代理,则以下操作对我有帮助。

取消设置代理使用:
1.打开Powershell
2.输入以下内容:

1
2
[Environment]::SetEnvironmentVariable("HTTP_PROXY", $null, [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", $null, [EnvironmentVariableTarget]::Machine)

要再次设置代理,请使用:
1.打开Powershell
2.输入以下内容:

1
2
[Environment]::SetEnvironmentVariable("HTTP_PROXY","http://yourproxy.com:yourportnumber", [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY","http://yourproxy.com:yourportnumber", [EnvironmentVariableTarget]::Machine)