将 git 代理重置为默认配置

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

#!/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 来使用它:

$ git config --global core.gitproxy gitproxy

现在我想将 git 重置为默认的代理配置,我该如何做呢?

151292 次浏览

You can remove that configuration with:

git config --global --unset core.gitproxy

For me, I had to add:

git config --global --unset http.proxy

Basically, you can run:

git config --global -l

to get the list of all proxy defined, and then use "--unset" to disable them

Edit .gitconfig file (Probably in your home directory of the user ~) and change the http and https proxy fields to space only

[http]
proxy =
[https]
proxy =

That worked for me in the windows.

On my Linux machine :

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)

I found out my https_proxy and http_proxy are set, so I just unset them.

unset https_proxy
unset http_proxy

On my Windows machine :

set https_proxy=""
set http_proxy=""

Optionally use setx to set environment variables permanently on Windows and set system environment using "/m"

setx https_proxy=""
setx http_proxy=""

Remove both http and https setting by using commands.

git config --global --unset http.proxy

git config --global --unset https.proxy

git config --global --unset http.proxy

If you have used Powershell commands to set the Proxy on windows machine doing the below helped me.

To unset the proxy use: 1. Open powershell 2. Enter the following:

[Environment]::SetEnvironmentVariable(“HTTP_PROXY”, $null, [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable(“HTTPS_PROXY”, $null, [EnvironmentVariableTarget]::Machine)

To set the proxy again use: 1. Open powershell 2. Enter the following:

[Environment]::SetEnvironmentVariable(“HTTP_PROXY”, “http://yourproxy.com:yourportnumber”, [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable(“HTTPS_PROXY”, “http://yourproxy.com:yourportnumber”, [EnvironmentVariableTarget]::Machine)

If running

git config --global --unset http.proxy

gives a warning:

http.proxy has multiple values

and none of the proxies are removed, then add "-all" in the command:

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

to successfully remove all proxies.

You can check it with:

git config --global --list