46

When I try to clone from git

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

I get an error

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

I'm connected directly to the internet (without proxy). I tried to turn off firewall and didn't help. I'm on windows and just installed Git-1.7.10-preview20120409.exe from http://code.google.com/p/msysgit/downloads/list . Previously I had 1.7.8 and this command worked. I also reinstalled TortoiseGit but I think it doesn't matter.

My C:\Documents and Settings\xxx\.gitconfig file is

[http]
    proxy = 
[user]
    name = xxxx
    email = [email protected]
2
  • the command worked for me so it has to be something with your settings. did you start the cmd.exe with administration rights? do you have a proxy program running or any kind of software to anonymize your system?
    – p0rter
    Commented Apr 26, 2012 at 13:01
  • I don't have any proxy running and I tried all this with admin rights. I can push changes using TortoiseGit
    – koral
    Commented Apr 26, 2012 at 16:44

14 Answers 14

133

Seems the problem is reported in the mailing list. Does this help?

git config --global --unset http.proxy
6
  • 1
    I added my file "c:\Documents and Settings\xxx\.gitconfig" to the question body.
    – koral
    Commented Apr 26, 2012 at 16:46
  • 1
    thanks man. this helped me at my office under firewall. Solved the bower proxy issue too
    – STEEL
    Commented Jun 10, 2014 at 10:06
  • Awesome! I had a problem with my work laptop VPN'ing into my work network and came across this answer that saved me a lot of time!
    – jamki
    Commented Aug 16, 2014 at 11:12
  • 1
    This helped me, almost 4 years after this answer. I can't git clone with http.proxy, but I can't git commit without it. Office proxies. Can't live with it, can't live without...my salary :( Commented Jan 8, 2016 at 6:37
  • 1
    the link is broken
    – Atty
    Commented May 14, 2018 at 12:18
10

Run the below command in git bash

git config --global --unset http.proxy

Note: Don't forget to restart the git bash, otherwise it won't work.

Also make sure to remove HTTPS_PROXY and HTTP_PROXY environment variables.


If the above steps didn't work for you, try setting your companies proxy as shown below;

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

**change example.com/8080 with your companies proxy and port

2
  • 1
    I am thanking you for the solution "remove HTTPS_PROXY and HTTP_PROXY environment variables." Commented Sep 14, 2018 at 14:10
  • The note to restart the git bash fixed it for me. Thanks!
    – ponder275
    Commented Aug 12, 2019 at 2:30
7

I just got the same issue, when pushing behind a firewall.

The problem wasn't an empty http_proxy var (git var -l didn't show any proxy variable), and my OS environment variables included:

http_proxy=username:[email protected]:port
https_proxy=username:[email protected]:port
no_proxy=.company

This setting would always trigger a:

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

However, as soon I changed the proxy variables, adding an 'http://' in front of the proxy addresses, the error message stopped:

http_proxy=http://username:[email protected]:port
https_proxy=http://username:[email protected]:port
no_proxy=.company

(note the 'http://' even for the https proxy address)

7

Just delete the

 [http]
     proxy =

worked for me

3
  • 1
    Where can those lines be found? I am working with TortoiseGit and none of the config files I found in the .git directory seemed to have anything named [http] or proxy. Commented Nov 26, 2015 at 15:53
  • You should be able to find them in your ~/.gitconfig file. Check this out too: (git-scm.com/docs/git-config#FILES)
    – Ubunfu
    Commented Mar 20, 2018 at 16:35
  • Thanks. My problem is solved. I used git config --global --unset http.proxy and your answer. Commented Nov 15, 2022 at 9:33
6

I have two work environments, when I'm at the company and when I'm at home. So, every single day I have to set and unset proxy variables to get my git running. What I found efficient was to create two bash files, one for setting the proxy variables and another one for "unsetting" it. So, whenever I arrive home or at work, all I have to do is to double click the files with admin rights and I'm done. The files are really simple:

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

The sleep 5 at the end is only to keep the window open for some seconds to verify if all commands ran correctly.

1
  • It's working for my office laptop.. Thanks for sharing the knowledge.
    – vijay sahu
    Commented Oct 27, 2019 at 10:27
3

Thanks @VonC for the answer.

Though it dint work for me your way, I used your answer as reference to have my work-around.

I had configured below environment variables to solve one of the cloud foundry dev environment issue. And all of sudden my git clone raised alarms saying couldn't resolve proxy. I just removed these environment variables and git clone working well.

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

Hope that helps.

1
  • 6 years later (after my original answer): great! Well done.
    – VonC
    Commented Oct 5, 2018 at 6:16
2

Just delete the

 [http]
     proxy = 

block in the Git global config file. (git version 1.7.10.msysgit.1 , windows XP)

The command line command mentioned in positron's answer doesn't work:

 git config --global --unset http.proxy

 error: unknown switch `â'
2
  • Seems like you re inputting some wrong switch. It never said to me like that, and for anyone too ;)
    – positron
    Commented May 25, 2012 at 10:04
  • Thanks for your input, yes, there is a wrong switch in your above command line. "-–unset" the second switch is wrong.
    – tss
    Commented May 28, 2012 at 10:04
1

Type the following commands.

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

    Here, example.com is the proxy server and 8080 is the port number.

  2. See to that you have set the proxy server.

  3. Then, do cloning the required repository. It will work.

I tried these in Windows.

1

First try to reset the Github proxy. Sometimes it might be issue with proxy server.

git config --global --unset http.proxy

Then restart the terminal and try again to clone the repository.

If still you are getting error, then you have to try to set the proxy using the following command.

git config --global http.proxy http://proxyUsername:[email protected]:port
0

the proxy should start with "http" or "https"

e.g.

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

I had same problem with running git on CentOS 6.5. Running the same command on Ubuntu worked fine. Git seemed to have a problem with the colon in the url. Anyway, the solution ended up being that I had to explicitly specify the port in the url, e.g.:

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

This error comes because Proxy which is you used. Even you add Proxy setting to your PC there will be some errors. Because the system setting changing is not enough to GIT. So your should config git for proxy.

git config --global http.proxy http://proxyUsername:[email protected]:port

Here proxyUsername is the user name that you use and proxyPassword is its password. proxy.server.com means proxy server name and port is the port that use for proxy. If you use specific Domain use this code :

git config --global http.https://domain.com.proxy http://proxyUsername:[email protected]:port
0

when you use this command on Ubuntu, use 'sudo' to get administrative permission in the begging of 'git clone'

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

0

In order to activate/deactivate proxy for git, I use two shell functions in ~/.bashrc:

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
}

These will uncomment/comment the [http] and [https] proxy entries in ~/.gitconfig respectively. Just type in the terminal, proxy_set or proxy_unset and you're all set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.