git 拒绝无代理连接

git refuses to connect without proxy

我在 Windows 环境中的 Linux 系统上工作。为了使用 NT 代理服务器进行身份验证,我设置了 cntlm 并配置了系统程序以通过在 /etc/environment 文件中设置 http_proxy 环境变量来使用它。

现在我想删除此代理设置并让程序直接连接。

所以我取消设置了系统环境变量:

unset http_proxy
unset HTTP_PROXY

检查 ~/.gitconfig 以确保没有代理条目。

明确指示git不要使用任何代理:

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

确认没有配置代理:

git config --system --get https.proxy 
git config --global --get https.proxy 
git config --system --get http.proxy 
git config --global --get http.proxy 

然后推送到远程仓库:

git push

但是git仍然尝试通过代理连接:

fatal: unable to access 'https://xxx@bitbucket.org/xxx.git/': Failed to connect to 127.0.0.1 port 3128: Connection refused

为什么不放手cntlm

最简单的检查是:

env|grep -i proxy

OP 确认:

I thought I had removed proxy by unset http_proxy.
But there is a different environment variable for HTTPS which needs to be unset separately. Running env|grep -i proxy revealed that.

  1. 使用 cat ~/. 这将列出所有文件。
  2. 使用cat ~/.gitconfig这将打开文件的内容。
  3. 如果你在那里发现任何代理,请将其删除

    [http] 代理 = http://127.0.0.1:3128

  4. 您可以使用 nano ~/.gitconfig 命令删除它。

  5. 现在这个命令可以工作了。

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

还记得删除所有代理,例如

unset http_proxy="http_proxy"
unset https_proxy=$http_proxy
unset ftp_proxy=$http_proxy
unset rsync_proxy=$http_proxy
unset HTTP_PROXY=$http_proxy
unset HTTPS_PROXY=$http_proxy
unset FTP_PROXY=$http_proxy
unset RSYNC_PROXY=$http_proxy

记得从系统首选项网络中删除代理,现在尝试取消选中代理的所有复选框。