问题 git - 无法解析代理:


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

在工作中我设置代理如:

    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 repo推送一些东西

    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]

如何删除代理?


10193
2017-12-11 18:49


起源

你有它定义为环境变量HTTP_PROXY?或者在repo(.git / config)的本地配置中? - VonC
我没有看到代理条目。你试过git config --global --unset http.proxy吗?应该有一个[http] proxy =条目,但它不在那里 - unixmiah
VonC - 我认为我没有将它定义为环境变量,我将如何/在哪里检查。 unixmiah - 是的我已经尝试过git config --global --unset http.proxy,这是我的问题。我知道没有代理条目,这就是为什么我很困惑。 - ttmt


答案:


检查环境变量:

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

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

$export http_proxy=

9
2018-03-26 07:35





  • 如果设置了以下变量,则在没有代理的网络上工作时只删除所有(示例@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
    

这两个步骤在Windows中共同起作用。


5
2017-09-11 14:26





与其他答案(尤其是@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)。 然后启动一个新的终端窗口(将重新加载环境变量)。如果您没有启动新的终端窗口,任何现有窗口仍将设置变量,需要手动清除。


0
2018-02-05 23:58