将git代理重置为默认配置


87

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

#!/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重置为默认代理配置,我该怎么做?

Answers:


92

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

git config --global --unset core.gitproxy

18
对我不起作用..我用过了git config --global --unset http.proxy,一切都很好
Ghassen

git config --global --unset http.proxy也为我工作。
Mayank

173

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

git config --global --unset http.proxy

基本上,您可以运行:

git config --global -l 

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


5
对于https,请使用git config --global --unset https.proxy
Abhishek Dhote 2014年

2
一件令人讨厌的事情--unset是,它离开了该部分的标题,因此您最终可能会[http]污染多个空部分.gitconfig。使用config --global --remove-section http删除整个[http]部分,包括标题。
thdoan '16

21

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

[http]
    proxy = 
[https]
    proxy = 

在窗户上对我有用。


20

在我的Linux机器上:

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已经设置,所以我只是取消设置它们。

unset https_proxy
unset http_proxy

在我的Windows机器上:

set https_proxy=""
set http_proxy=""

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

setx https_proxy=""
setx http_proxy=""

12

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

git config --global --unset http.proxy

git config --global --unset https.proxy



0

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

取消设置代理服务器使用方法:1。打开PowerShell中输入以下:

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

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

[Environment]::SetEnvironmentVariable(“HTTP_PROXY”, “http://yourproxy.com:yourportnumber”, [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable(“HTTPS_PROXY”, “http://yourproxy.com:yourportnumber”, [EnvironmentVariableTarget]::Machine)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.