git - 无法解析代理:

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

git - Could not resolve proxy:

gitproxy

提问by ttmt

In work I have a proxy, at home I don't have a proxy

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

In work I set the proxy like:

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

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

At home I remove the proxy like

在家里,我删除了代理

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

I'm trying to push something to my git repo with

我正在尝试将某些内容推送到我的 git repo

    git push -u origin master

And I get

我得到

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

The .gitconfig file looks like this.

.gitconfig 文件看起来像这样。

    [user]
        name = first last
        email = [email protected]
    [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]

How do I remove the proxy ?

如何删除代理?

回答by harip

Check the environment variables with :

使用以下命令检查环境变量:

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

if any of these environment variables are set then unset them by just using http_proxy=then enterwill unset those

如果设置了这些环境变量中的任何一个,则只需使用http_proxy=then 即可enter取消设置它们

$export http_proxy=

回答by Satishakumar Awati

  • If below variables are set just delete all when working on network without proxy (Example @home)

    //Computer=>System properties=>Advanced=>Environment Variables
    
    http_proxy,https_proxy,HTTPS_PROXY,HTTP_PROXY
    
  • Unset git proxy

    git config --global --unset http.proxy
    git config --global --unset https.proxy
    
  • 如果设置了以下变量,则在没有代理的网络上工作时删除所有变量(例如@home)

    //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
    

Both steps together worked for me in Windows.

这两个步骤在 Windows 中都对我有用。

回答by kwriter

Similar to other answers (especially the one by @harip) but if you're on a Mac or such, check the .bash_profile file in the user's home directory (e.g. cat ~/.bash_profile). Mine had these set during another program's install:

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

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

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

Move that file to the side (e.g. mv ~/.bash_profile ~/.bash_profile-hide). Then start a new Terminal window (which will reload environment variables). If you don't start a new Terminal window, any existing ones will still have the variables set and need to be cleared manually.

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