Git: 如何删除代理

我试图推动回购,但收到一个错误:

fatal: unable to access 'https://github.com/myrepo.git/': Could not resolve proxy: --list

我已经更改了代理设置:

git config --global --unset http.proxy

我的全局配置设置是:

push.default=simple
http.sslverify=false
url.https://.insteadof=git://
credential.helper=cache --timeout=3600

但仍然得到这个错误? 我该如何解决这个问题?

186099 次浏览

Check if you have environment variable that could still define a proxy (picked up by curl, even if the git config does not include any proxy setting anymore):

HTTP_PROXY
HTTPS_PROXY

Check your enviroment:

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

and delete with export http_proxy=

Or check https and http proxy

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

Or do you have the proxy in the local config?

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

Did you already check your proxys here?

git config --global --list

or

git config --local --list

This is in the case if first answer does not work The latest version of git does not require to set proxy it directly uses system proxy settings .so just do these

unset HTTP_PROXY
unset HTTPS_PROXY

in some systems you may also have to do

unset http_proxy
unset https_proxy

if you want to permanantly remove proxy then

sudo gsettings set org.gnome.system.proxy mode 'none'

You config proxy settings for some network and now you connect another network. Now have to remove the proxy settings. For that use these commands:

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

Now you can push too. (If did not remove proxy configuration still you can use git commands like add , commit and etc)

You can list all the global settings using

git config --global --list

My proxy settings were set as

...
remote.origin.proxy=
remote.origin.proxy=address:port
...

The command git config --global --unset remote.origin.proxy did not work.

So I found the global .gitconfig file it was in, using this

git config --list --show-origin

And manually removed the proxy fields.

Some times, local config command won't show the proxy but it wont allow git push due to proxy. Run the following commands within the directory and see.

#git config --local --list

But the following commands displays the proxy set to local repository:

#git config http.proxy
#git config https.proxy

If the above command displays any proxy then clear it by running the following commands:

#git config https.proxy ""
#git config https.proxy ""
git config --global --unset http.proxy
git config --unset http.proxy
http_proxy=""

If you already unset the proxy from global and local level and still see the proxy details while you do

         git config -l

then unset the variable from system level, generally the configuration stored at below location

 C:\Program Files\Git\mingw64/etc/gitconfig

if you used remote.origin.proxy( check it by using git config --global -l ) ,then use git config --global --unset-all remote.origin.proxy .

Use

git config -l --show-origin

We can find the file location, and delete:

[remote "origin"]
proxy =
proxy = 127.0.0.1:(proxy http port number)

For me it was just the IPV6 causing this error ! after uncheking the IPV6 option on the network adapter (and just using IPV4), the error disappeared !

Previous answers have mentioned the proxy settings in git itself. However, if you ever set an SSH proxy for your remote repository in your ssh settings in files like ~/.ssh/config etc., git uses the config to perform ssh connections.

For me, I configured an SSH proxy for all my GitHub repos:

# proxy github
Host github.com
User git
ProxyCommand nc -x $PROXY %h %p

Remove the settings solved my problem.