【问题标题】:git - Could not resolve proxy:git - 无法解析代理:
【发布时间】:2015-02-10 08:57:07
【问题描述】:

在工作中我有代理,在家里我没有代理

在工作中,我将代理设置为:

    git config - -global  http.proxy  http://proxy.theaddress.co.uk:8080
    git config - -global  https.proxy  https://proxy.theaddress.co.uk:8080

在家里我删除了类似的代理

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

我正在尝试将一些东西推送到我的 git 存储库

    git push -u origin master

我得到了

    Could not resolve proxy: proxy.theaddress.co.uk

.gitconfig 文件如下所示。

    [user]
        name = first last
        email = first.last@sitname.co.uk
    [http]
    [https]
    [push]
        default = current
    [http]
    [core]
        excludesfile = /Users/first.last/.gitignore_global
    [difftool "sourcetree"]
        cmd = opendiff \"$LOCAL\" \"$REMOTE\"
        path = 
    [mergetool "sourcetree"]
        cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
        trustExitCode = true
    [http]
    [https]
    [http]
    [https]
    [http]
    [https]
    [http]
    [https]
    [http]
    [https]
    [filter "media"]
        clean = git media clean %f
        smudge = git media smudge %f
        required = true
    [http]
    [https]
    [https]
    [http]
    [http]
    [https]
    [http]

如何删除代理?

【问题讨论】:

  • 您是否将其定义为环境变量 HTTP_PROXY?还是在 repo (.git/config) 的本地配置中?
  • 我没有看到代理条目。你试过 git config --global --unset http.proxy 吗?应该有一个 [http] proxy = entry 但它不存在
  • VonC - 我认为我没有将它定义为环境变量,我将如何/在哪里检查。 unixmiah - 是的,我试过 git config --global --unset http.proxy,这是我的问题。我知道没有代理条目,这就是我感到困惑的原因。

标签: git proxy


【解决方案1】:
  • 如果在没有代理的网络上工作时设置了以下所有变量(在家中的示例)

     //Computer=>System properties=>Advanced=>Environment Variables
     http_proxy,https_proxy,HTTPS_PROXY,HTTP_PROXY
    
  • 取消设置 git 代理

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

这两个步骤一起在 Windows 中为我工作。

【讨论】:

    【解决方案2】:

    解决此问题的方法是删除 git 代理。

    • 通过管理员打开终端。
    • 然后点击命令git config --global -l
    • 然后通过以下命令取消设置所有 HTTP 和 https 代理
    • git config --global --unset-all http.proxy & git config --global --unset-all https.proxy
    • 现在您可以使用相同的命令git config --global -l 检查它是否已从列表中删除

    【讨论】:

      【解决方案3】:

      与其他答案类似(尤其是@harip 的答案),但如果您使用的是 Mac 或类似设备,请检查用户主目录中的 .bash_profile 文件(例如cat ~/.bash_profile)。 我的在另一个程序的安装过程中设置了这些:

      export HTTP_PROXY=http://proxy.somewhere.com:80
      
      export HTTPS_PROXY=http://proxy.somewhere.com:80
      

      将该文件移到一边(例如mv ~/.bash_profile ~/.bash_profile-hide)。 然后启动一个新的终端窗口(它将重新加载环境变量)。如果您不启动新的终端窗口,任何现有的仍将设置变量并需要手动清除。

      【讨论】:

        【解决方案4】:

        检查环境变量:

        $echo $http_proxy
        $echo $https_proxy
        $echo $HTTPS_PROXY
        $echo $HTTP_PROXY
        

        如果设置了这些环境变量中的任何一个,则只需使用http_proxy= 将其取消设置,然后enter 将取消设置这些变量

        $export http_proxy=
        

        【讨论】:

        • mac os上是http.proxy吗?
        • 感谢@harip,它奏效了。您必须有足够的耐心检查所有四个版本!发现两三个回声空了不要放弃!
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-24
        • 2020-03-07
        • 1970-01-01
        • 1970-01-01
        • 2018-04-17
        相关资源
        最近更新 更多