git clone 无法解析代理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10333836/
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-10 13:33:41  来源:igfitidea点击:

git clone can't resolve proxy

git

提问by koral

When I try to clone from git

当我尝试从 git 克隆时

git clone "http://github.com/symfony/symfony.git" "d:/www/a/vendor/symfony"

I get an error

我收到一个错误

Cloning into 'd:/www/a/vendor/symfony'...
error: Couldn't resolve proxy '(null)' while accessing http://github.com/symfony/symfony.git/info/refs
fatal: HTTP request failed

I'm connected directly to the internet (without proxy). I tried to turn off firewall and didn't help. I'm on windows and just installed Git-1.7.10-preview20120409.exe from http://code.google.com/p/msysgit/downloads/list. Previously I had 1.7.8 and this command worked. I also reinstalled TortoiseGit but I think it doesn't matter.

我直接连接到互联网(没有代理)。我试图关闭防火墙并没有帮助。我在 Windows 上,刚刚从http://code.google.com/p/msysgit/downloads/list安装了 Git-1.7.10-preview20120409.exe 。以前我有 1.7.8 并且这个命令有效。我也重新安装了 TortoiseGit,但我认为没关系。

My C:\Documents and Settings\xxx\.gitconfigfile is

我的C:\Documents and Settings\xxx\.gitconfig文件是

[http]
    proxy = 
[user]
    name = xxxx
    email = [email protected]

回答by positron

Seems the problem is reported in the mailing list. Does thishelp?

似乎问题已在邮件列表中报告。请问帮助?

git config --global --unset http.proxy

回答by Naresh Chennuri

Run the below command in git bash

在 git bash 中运行以下命令

git config --global --unset http.proxy

Note: Don't forget to restart the git bash, otherwise it won't work.

注意:不要忘记重新启动git bash,否则将无法工作。

Also make sure to remove HTTPS_PROXY and HTTP_PROXY environment variables.

还要确保删除 HTTPS_PROXY 和 HTTP_PROXY 环境变量。



If the above steps didn't work for you, try setting your companies proxy as shown below;

如果上述步骤对您不起作用,请尝试如下设置您的公司代理;

git config --global  http://example.com:8080
git config --global  https://example.com:8080

**change example.com/8080 with your companies proxy and port

**使用您公司的代理和端口更改example.com/8080

回答by VonC

I just got the same issue, when pushing behind a firewall.

当我推到防火墙后面时,我遇到了同样的问题。

The problem wasn't an empty http_proxy var (git var -l didn't show any proxy variable), and my OS environment variables included:

问题不是一个空的 http_proxy var(git var -l 没有显示任何代理变量),我的操作系统环境变量包括:

http_proxy=username:[email protected]:port
https_proxy=username:[email protected]:port
no_proxy=.company

This setting would always trigger a:

此设置将始终触发:

error: Couldn't resolve proxy '(null)' while accessing https://...

However, as soon I changed the proxy variables, adding an 'http://' in front of the proxy addresses, the error message stopped:

但是,一旦我更改了代理变量,在代理地址前面添加了一个“ http://”,错误消息就停止了

http_proxy=http://username:[email protected]:port
https_proxy=http://username:[email protected]:port
no_proxy=.company

(note the 'http://' even for the https proxy address)

(注意 ' http://' 即使是 https 代理地址)

回答by FTM

I have two work environments, when I'm at the company and when I'm at home. So, every single day I have to set and unset proxy variables to get my git running. What I found efficient was to create two bash files, one for setting the proxy variables and another one for "unsetting" it. So, whenever I arrive home or at work, all I have to do is to double click the files with admin rights and I'm done. The files are really simple:

我有两种工作环境,在公司和在家里。所以,每一天我都必须设置和取消设置代理变量才能让我的 git 运行。我发现有效的是创建两个 bash 文件,一个用于设置代理变量,另一个用于“取消设置”它。因此,每当我回到家或上班时,我所要做的就是双击具有管理员权限的文件,我就完成了。这些文件非常简单:

unset-proxy.bat

未设置代理.bat

setx HTTP_PROXY ""
setx HTTPS_PROXY ""
setx HTTP_PROXY "" /M
setx HTTPS_PROXY "" /M
git config --global --unset http.proxy
git config --global --unset https.proxy
sleep 5

set-proxy.bat

设置代理.bat

setx HTTP_PROXY <your proxy here>
setx HTTPS_PROXY <your proxy here>
setx HTTP_PROXY <your proxy here> /M
setx HTTPS_PROXY <your proxy here> /M
git config --global <your proxy here>
git config --global <your proxy here>
sleep 5

The sleep 5at the end is only to keep the window open for some seconds to verify if all commands ran correctly.

sleep 5在年底只保留窗口打开几秒钟,以验证是否所有命令正确运行。

回答by Victor J. Garcia

Just delete the

只需删除

 [http]
     proxy =

worked for me

对我来说有效

回答by Rohan P

Thanks @VonC for the answer.

感谢@VonC 的回答。

Though it dint work for me your way, I used your answer as reference to have my work-around.

虽然它对我有用,但我使用你的答案作为参考来解决我的问题。

I had configured below environment variables to solve one of the cloud foundry dev environment issue. And all of sudden my git clone raised alarms saying couldn't resolve proxy. I just removed these environment variables and git clone working well.

我配置了以下环境变量来解决云代工厂开发环境问题之一。突然间,我的 git clone 发出警报,说无法解析代理。我刚刚删除了这些环境变量,并且 git clone 运行良好。

http_proxy=proxy.company:port
https_proxy=proxy.company:port

Hope that helps.

希望有帮助。

回答by tss

Just delete the

只需删除

 [http]
     proxy = 

block in the Git global config file. (git version 1.7.10.msysgit.1 , windows XP)

在 Git 全局配置文件中阻止。(git 版本 1.7.10.msysgit.1 ,Windows XP)

The command line command mentioned in positron's answer doesn't work:

正电子的回答中提到的命令行命令不起作用:

 git config --global --unset http.proxy

 error: unknown switch `a'

回答by Prem Kumar

Type the following commands.

键入以下命令。

  1. git config --global http.proxy example.com:8080

    Here, example.comis the proxy server and 8080is the port number.

  2. See to that you have set the proxy server.

  3. Then, do cloning the required repository. It will work.

  1. git config --global http.proxy example.com:8080

    这里,example.com是代理服务器,8080是端口号。

  2. 确保您已设置代理服务器。

  3. 然后,克隆所需的存储库。它会起作用。

I tried these in Windows.

我在 Windows 中尝试过这些。

回答by Gene

the proxy should start with "http" or "https"

代理应以“http”或“https”开头

e.g.

例如

abc.proxy.com:8080 may not work
http://abc.proxy.com:8080 should work

回答by adelaidedave

I had same problem with running git on CentOS 6.5. Running the same command on Ubuntu worked fine. Git seemed to have a problem with the colon in the url. Anyway, the solution ended up being that I had to explicitly specify the port in the url, e.g.:

我在 CentOS 6.5 上运行 git 时遇到了同样的问题。在 Ubuntu 上运行相同的命令工作正常。Git 似乎对 url 中的冒号有问题。无论如何,解决方案最终是我必须在 url 中明确指定端口,例如:

git clone https://example.edu.au:443/git/master.git