【问题标题】:git clone can't resolve proxygit clone 无法解析代理
【发布时间】:2012-04-26 12:54:06
【问题描述】:

当我尝试从 git 克隆时

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

我收到一个错误

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

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

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

[http]
    proxy = 
[user]
    name = xxxx
    email = xxx@example.com

【问题讨论】:

  • 该命令对我有用,因此它必须与您的设置有关。您是否使用管理权限启动了 cmd.exe?您是否正在运行代理程序或任何类型的软件来匿名您的系统?
  • 我没有运行任何代理,我用管理员权限尝试了所有这些。我可以使用 TortoiseGit 推送更改

标签: git


【解决方案1】:

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

git config --global --unset http.proxy

【讨论】:

  • 我将文件“c:\Documents and Settings\xxx\.gitconfig”添加到问题正文中。
  • 谢谢伙计。这对我在防火墙下的办公室很有帮助。也解决了凉亭代理问题
  • 太棒了!我的工作笔记本电脑 VPN 连接到我的工作网络时遇到问题,我遇到了这个答案,为我节省了很多时间!
  • 这对我有帮助,在这个答案之后将近 4 年。我无法使用 http.proxy 进行 git clone,但没有它我无法 git commit。办公室代理。不能忍受,不能没有......我的薪水:(
  • 链接失效
【解决方案2】:

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

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

http_proxy=username:passowrd@proxy.company:port
https_proxy=username:passowrd@proxy.company:port
no_proxy=.company

这个设置总是会触发:

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

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

http_proxy=http://username:passowrd@proxy.company:port
https_proxy=http://username:passowrd@proxy.company:port
no_proxy=.company

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

【讨论】:

    【解决方案3】:

    在 git bash 中运行以下命令

    git config --global --unset http.proxy
    

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

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


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

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

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

    【讨论】:

    • 感谢您提供“删除 HTTPS_PROXY 和 HTTP_PROXY 环境变量”的解决方案。
    • 重启 git bash 的注释为我修复了它。谢谢!
    【解决方案4】:

    只需删除

     [http]
         proxy =
    

    为我工作

    【讨论】:

    • 在哪里可以找到这些行?我正在使用 TortoiseGit,我在 .git 目录中找到的所有配置文件似乎都没有任何名为 [http]proxy 的内容。
    • 您应该能够在 ~/.gitconfig 文件中找到它们。也看看这个:(git-scm.com/docs/git-config#FILES)
    【解决方案5】:

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

    unset-proxy.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

    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
    

    末尾的sleep 5 只是为了让窗口保持打开几秒钟,以验证所有命令是否运行正确。

    【讨论】:

    • 它适用于我的办公室笔记本电脑。感谢分享知识。
    【解决方案6】:

    感谢@VonC 的回答。

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

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

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

    希望对您有所帮助。

    【讨论】:

    • 6 年后(在我原来的回答之后):太好了!干得好。
    【解决方案7】:

    只需删除

     [http]
         proxy = 
    

    Git 全局配置文件中的块。 (git 版本 1.7.10.msysgit.1 , windows XP)

    positron 的回答中提到的命令行命令不起作用:

     git config --global --unset http.proxy
    
     error: unknown switch `â'
    

    【讨论】:

    • 好像你输入了一些错误的开关。它从来没有这样对我说过,对任何人也是如此;)
    • 感谢您的输入,是的,您上面的命令行中有一个错误的开关。 “--unset”第二个开关是错误的。
    【解决方案8】:

    键入以下命令。

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

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

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

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

    我在 Windows 中尝试过这些。

    【讨论】:

      【解决方案9】:

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

      例如

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

      【讨论】:

        【解决方案10】:

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

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

        【讨论】:

          【解决方案11】:

          出现此错误是因为您使用了代理。即使您将代理设置添加到您的 PC,也会有一些错误。因为系统设置更改对 GIT 来说是不够的。所以你应该为代理配置 git。

          git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
          

          这里 proxyUsername 是您使用的用户名,proxyPassword 是它的密码。 proxy.server.com 表示代理服务器名称,端口是用于代理的端口。 如果您使用特定域,请使用此代码:

          git config --global http.https://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
          

          【讨论】:

            【解决方案12】:

            当你在 Ubuntu 上使用这个命令时,在 'git clone' 的请求中使用 'sudo' 来获得管理权限

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

            【讨论】:

              【解决方案13】:

              首先尝试重置 Github 代理。有时可能是代理服务器的问题。

              git config --global --unset http.proxy
              

              然后重新启动终端并再次尝试克隆存储库。

              如果仍然出现错误,则必须尝试使用​​以下命令设置代理。

              git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
              

              【讨论】:

                【解决方案14】:

                为了激活/停用 git 的代理,我在 ~/.bashrc 中使用了两个 shell 函数:

                proxy_set() {
                    export http_proxy=http://PROXYADDR:PORT/
                    export https_proxy=https://PROXYADDR:PORT/
                    export socks_proxy=socks://PROXYADDR:PORT;
                    sed -i '/proxy =/s/^#//g' ~/.gitconfig
                }
                proxy_unset() {
                    unset http_proxy; unset https_proxy; unset socks_proxy;
                    sed -i '/proxy =/s/^#*/#/g' ~/.gitconfig
                }
                

                这些将分别取消注释/注释 ~/.gitconfig 中的 [http] 和 [https] 代理条目。 只需在终端输入 proxy_set 或 proxy_unset 即可。

                【讨论】:

                  猜你喜欢
                  • 2015-02-10
                  • 1970-01-01
                  • 2020-01-10
                  • 1970-01-01
                  • 2011-11-01
                  • 1970-01-01
                  • 2010-12-19
                  • 1970-01-01
                  • 2012-06-24
                  相关资源
                  最近更新 更多