git git拒绝在没有代理的情况下连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30828237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:07:02  来源:igfitidea点击:

git refuses to connect without proxy

gitproxy

提问by Kshitiz Sharma

I work on a Linux system in a Windows environment. To authenticate with a NT proxy server I had setup cntlmand configured system programs to use it via setting http_proxyenvironment variable in the /etc/environmentfile.

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

Now I want to remove this proxy setting and have the programs connect directly.

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

So I unset the system environment variables:

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

unset http_proxy
unset HTTP_PROXY

Check ~/.gitconfigto ensure that there are no proxy entries.

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

Explicitly instruct gitnot to use any proxies:

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

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

Verify that no proxy is configured:

验证没有配置代理:

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

And then push to a remote repo:

然后推送到远程仓库:

git push

But gitstill tries to connect via proxy:

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

fatal: unable to access 'https://[email protected]/xxx.git/': Failed to connect to 127.0.0.1 port 3128: Connection refused

致命:无法访问“ https://[email protected]/xxx.git/”:无法连接到 127.0.0.1 端口 3128:连接被拒绝

Why won't it let go off cntlm?

为什么不放手cntlm

回答by VonC

The easiest check to do is:

最简单的检查是:

env|grep -i proxy

The OP confirms:

OP确认:

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

我以为我已经proxy通过 unset删除了http_proxy
但是 HTTPS 有一个不同的环境变量,需要单独取消设置。跑步env|grep -i proxy揭示了这一点。

回答by venky

  1. use cat ~/.this will list all the files.
  2. use cat ~/.gitconfigthis will open the contents of file.
  3. If you find any proxies there remove it like

    [http] proxy = http://127.0.0.1:3128

  4. You can remove it by using nano ~/.gitconfigcommand.

  5. Now this command will work.

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

  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)"

ALSO REMEMBER to remove all the proxies like

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

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

Remember to remove proxies from system preferences network and proxies uncheck all the check boxes now try to do.

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