1032

How do I get Git to use a proxy server?

I need to check out code from a Git server, but it shows "Request timed out" every time. How do I get around this?

Alternatively, how can I set a proxy server?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Debajit
  • 46,327
  • 33
  • 91
  • 100
  • Wouldn't this be a git client configuration item? The only aspect of this that seems like would involve cmd.exe is that the git client may allow you to specify a proxy in an environement variable. – Michael Burr Apr 23 '09 at 22:42
  • I have edited the original question to remove all Windows references, as this problem is git-specific per se. – Debajit Jul 01 '10 at 19:44
  • 3
    Note that you will be able toon to [setup a proxy per git repo url!](http://stackoverflow.com/a/18712501/6309) – VonC Sep 10 '13 at 07:01
  • 1
    This question is very similar to "[How do I pull from a Git repository through an HTTP proxy?"](http://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy). – Derek Mahar Jul 11 '15 at 17:07
  • 5
    Most of the answers in this question go about HTTP proxies. If you have a SOCKS proxy, see [this question](https://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport) for the HTTP/S [protocols](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols) and [this one](https://stackoverflow.com/questions/5860888/git-through-proxy) for the git:// protocol. – user Mar 30 '17 at 10:28
  • Duplicate foud https://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy?noredirect=1&lq=1 – Trect Jul 10 '18 at 04:30
  • Another reason is [a DDoS attack](https://stackoverflow.com/questions/29333319/failed-to-connect-to-github-443) (I don't think it is covered in the existing answers). It is a merge candidate. – Peter Mortensen Feb 24 '23 at 05:40

21 Answers21

1815

The command to use:

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
  • change proxyuser to your proxy user
  • change proxypwd to your proxy password
  • change proxy.server.com to the URL of your proxy server
  • change 8080 to the proxy port configured on your proxy server

Note that this works for both HTTP and HTTPS repositories.

If you decide at any time to reset this proxy and work without proxy:

The command to use:

git config --global --unset http.proxy

Finally, to check the currently-set proxy:

git config --global --get http.proxy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Salim Hamidi
  • 20,731
  • 1
  • 26
  • 31
  • 18
    Thanks Salim. Mine worked without the proxyuser:proxypwd in the URL. – Kwex Jan 30 '14 at 15:45
  • Noy at all Kwex, we're welcome. RedX your proposal is more convinient so I add your answer to the post – Salim Hamidi Feb 02 '14 at 18:20
  • 12
    Thanks,guys. For me it was NTLM based authentication and just updating my .gitconfig didn't work :( . So I had to get CNTLM which uses NTLM authetication. All I had to do was point my CNTLM to my network's proxy server and then point my software update manager(like yum,apt-get or ssh) to the local proxy. In case of git operations like clone,pull the http.proxy was my locally configured proxy with the local server. – Mayur Nagekar Feb 04 '14 at 05:02
  • @SalimHamidi I'm using TOR for proxy. there is no username or special link! or even password! What can i do? – Dr.jacky Jun 19 '14 at 05:52
  • @Johan Karlsson can this help you ?: http://stackoverflow.com/questions/10274879/how-to-contribute-on-github-anonymously-via-tor – Salim Hamidi Jun 19 '14 at 10:06
  • 1
    In my case, it didn't work until I tried removing `http://` for both http and https. – MIWMIB Aug 07 '14 at 23:53
  • 1
    For me, the (non global) proxy settings were old and were shadowing the global settings. Not until I did git config --unset https.proxy and git config --unset http.proxy did it work – Julian Mann Aug 18 '14 at 23:44
  • use git config --local http.proxy http://... to store the proxy information in the current git repository. This is useful if you need to use the proxy only for some repositories. – waynix Aug 28 '14 at 08:16
  • 9
    Hello, how can I set proxypass if it have "@" character? I know I must scape this character but I don't know how.. Thank you – patricK Feb 13 '15 at 10:52
  • How to specify hosts that Git should not route through the proxy? – Thomas S. Feb 14 '15 at 08:11
  • Did not work on my Ubuntu 14.04. The corkscrew solution below worked for me. – Tobi Apr 07 '15 at 19:09
  • 14
    @patricK You can use `%40` as a replacement for the `@` in username/ password string, though I've not tested this myself. Hope it helps. :-) – Sourav Ghosh Jun 04 '15 at 07:00
  • Something that worked first time... I'm struggling to come to terms with that. Makes a refreshing change. – Dave Lawrence Jun 17 '15 at 15:00
  • 14
    @patricK I can confirm that using %40 as a replacement for @ works. It seems if a special character isn't working you should try URL encoding it. The encodings are found here: http://www.w3schools.com/tags/ref_urlencode.asp – Jon Jul 08 '15 at 18:36
  • looks like setting https.proxy does not work, but if you set http.proxy then https repositories accessing work – Sergei Krivonos Jan 09 '16 at 12:47
  • 1
    @Sergei is right in his comment. There is no documentation of `https.proxy` in the [git-config(1)](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) manual. It doesn't work. The `http.proxy` is the only documented option for HTTP proxy that works for both HTTP and HTTPS clone URLs. – Susam Pal Feb 14 '16 at 06:18
  • If you're getting "self signed certificate in certificate chain" errors, set http.sslVerify to false in the configuration – Kevin Shea Jun 13 '16 at 13:29
  • 1
    I have to point out that using `--global` when you are using `username@password` is a __bad__ idea as you are then letting every other user of the machine use your username & password. Use `--user` for any "global" setting that are specific to a user and --local for any that are specific to the checked out repo that you are currently in the directory for omitting the scope implies `--local` but it is nice to be specific. – Steve Barnes Apr 24 '17 at 05:51
  • in addition to @Steve Barnes' comment the gitconfig or .gitconfig file will save what you entered in plaintext: including your network username and password – Gavin Achtemeier Jul 06 '17 at 23:54
  • You may need to add the domain in the form http://DOMAIN\\proxyuser:proxypwd@proxy.server.com:8080 – blacelle Nov 15 '17 at 11:46
  • You might want to use the proxy system-wide for git. _git config --system http.proxy http://proxyuser:proxypwd@proxy.server.com:8080_ I had to use it to set up git for Checkmarx. – Evil Platypus Apr 24 '18 at 22:01
  • If you are in a Linux machine, simply setting the environment variable should work, like the one I did on this page: https://note.tianhaoz.com/linux-tricks/bashrc.html – Tianhao Zhou May 28 '19 at 21:02
  • This is the easiest way to config proxy. – Dinith Oct 21 '19 at 09:58
  • I had to add `git config --global http.sslVerify false` afterwards. – Gabriel Ziegler Jul 06 '20 at 18:30
  • Does anyone know if this passes your Username:Password as plain text in the HTTP/S request? (Is git sending http requests or https requests to my proxy?) – user1567453 Oct 18 '21 at 06:27
  • the proxy address may not always be HTTP protocol, In my case, I use socks protocol, so `git config --global https.proxy 'socks://127.0.0.1:1088' ` works for me – Liu Hao May 07 '22 at 18:01
140

This worked for me, in Windows XP behind a corporate firewall.

I didn’t have to install any local proxy or any other software besides git v1.771 from http://code.google.com/p/msysgit/downloads/list?can=3

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --system http.sslcainfo /bin/curl-ca-bundle.crt
git remote add origin https://mygithubuser:mygithubpwd@github.com/repoUser/repoName.git
git push origin master

proxyuser = the proxy user I was assigned by our IT department. In my case, it is the same Windows user I use to log in to my PC, the Active Directory user.

proxypwd = the password of my proxy user

proxy.server.com:8080 = the proxy name and port, I got it from Control Panel, Internet Options, Connections, LAN Settings button, Advanced button inside the Proxy Server section, use the servername and port on the first (http) row.

mygithubuser = the user I use to log in to github.com

mygithubpwd = the password for my github.com user

repoUser = the user owner of the repository

repoName = the name of the repository

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alvaro
  • 2,676
  • 2
  • 20
  • 19
  • 2
    Hooray, thanks! `git config --global http.sslcainfo MY_NEW_CERTS_BUNDLE.crt` plus certificates downloaded as described in http://www.simplicidade.org/notes/archives/2011/06/github_ssl_ca_errors.html (thanks to: http://stackoverflow.com/a/7206627/98528) did it for me! – akavel May 23 '12 at 14:31
  • @Pablolic Doing the first two steps itself did the trick for me. Thank you so much. +1 – Ayusman Jun 12 '12 at 23:05
  • 3
    Seems to work for me, but git still doesn't work when I ask it to clone a repository using the `git://` protocol. – Ajedi32 Nov 02 '12 at 15:03
  • 4
    A couple of clarifications to pablolic's information, based on what worked for me: 1) If proxyuser is a Windows login, leave out the AD domain, just include the user name without the domain; 2) Spaces in the proxypwd should be encoded as "+". eg "My Password" should be entered as "My+Password". – Simon Elms Jan 11 '13 at 03:48
  • @SimonTewsi any idea what to do if your password contains @ – EdmundYeung99 Mar 21 '13 at 22:30
  • @Ajedi32: Firewalls are often specific about which ports allow traffic. Git protocol uses port 9418 which may not be allowed. Try `https` or `http` if available from the remote Git repo allows. – kevinarpe Apr 23 '13 at 09:54
  • 3
    @EdmundYeung99: I'd suggest replacing the @ symbol with %40. Haven't tried it but I believe that is standard URL encoding. – Simon Elms May 05 '13 at 12:03
  • @SimonTewsi What about dollar signs in the password? My http.proxy does not seem to save right because of this character – demongolem Jun 04 '13 at 12:46
  • 2
    @demongolem: I suspect you may need to URL encode your password (haven't tried it, this is just an educated guess). See UrlEncoded column in the table in the following answer: http://stackoverflow.com/a/11236038/216440 In your case that would mean replacing the $ with %24. – Simon Elms Jun 06 '13 at 06:23
  • What if then I want to disable the proxy in config? Can't set it to empty – Rayjax Oct 06 '13 at 08:04
  • Found a way, not too sure if it is the best, git config --global http.proxy "" – Rayjax Oct 06 '13 at 08:12
  • You have posted this exact answer numerous times. If it truly applies to all the other posts, you should have flagged them as duplicates. Your recent unnecessary, minor edits brought these to light. I am leaving this one as it is the highest-voted of them. – Andrew Barber Dec 31 '13 at 22:34
  • so what if i want to use tor to work with git? how i should configure git proxy to tor??? –  Jan 14 '17 at 23:42
56

Set a system variable named http_proxy with the value of ProxyServer:Port. That is the simplest solution. Respectively, use https_proxy as daefu pointed out in the comments.

Setting gitproxy (as sleske mentions) is another option, but that requires a "command", which is not as straightforward as the above solution.

References: Use Git behind a proxy

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Debajit
  • 46,327
  • 33
  • 91
  • 100
  • 10
    Or use 'https_proxy' if you're connecting to a https-repository. – daefu Dec 06 '11 at 07:39
  • 1
    @daefu: Not sure if you need to set https_proxy. I'm connected to an https repository and followed the first step of pablolic's instructions (ie adding http.proxy to the git config file). That was all it took for me. – Simon Elms Jan 11 '13 at 03:41
  • 3
    https_proxy was required for me. Setting only http_proxy did not allow it to clone an HTTPS repo – explunit Feb 18 '13 at 15:17
  • @daefu +1 this also works with widows github - related question : http://stackoverflow.com/questions/16216176/git-for-windows-unable-to-clone-repository – blue-sky Apr 26 '13 at 10:16
  • 4
    @SimonTewsi @explunit While setting environment variables `http_proxy` is required for HTTP URLs and `https_proxy` is required for HTTPS URLs. Alternatively, one could just set `all_proxy` for all URLs. See `ENVIRONMENT` section in [curl(1)](https://curl.haxx.se/docs/manpage.html). However, while setting git-config options, `http.proxy` is used for both HTTP and HTTPS URLs. See `http.proxy` in [git-config(1)](https://www.kernel.org/pub/software/scm/git/docs/git-config.html). – Susam Pal Feb 14 '16 at 06:23
  • 1
    This gave me `The requested URL returned error: 501`. – Ciro Santilli OurBigBook.com Jan 04 '18 at 15:23
54

As an alternative to using git config --global http.proxy address:port, you can set the proxy on the command line:

git -c "http.proxy=address:port" clone https://...

The advantage is the proxy is not persistently set. Under Bash you might set an alias:

alias git-proxy='git -c "http.proxy=address:port"'
Steve Pitchers
  • 7,088
  • 5
  • 41
  • 41
  • For me this only worked if I included the scheme (="http://") in the variable value, so `git -c "http.proxy=http://address:port"` – Tobias Jul 14 '23 at 09:42
47

If the command line way of configuring your proxy server doesn't work, you can probably just edit .gitconfig (in the root of your profile, which may hide both in C:\Documents and Settings and on some network drive) and add this:

[http]
    proxy = http://username:password@proxy.at.your.org:8080

Your mileage may vary though. This only covers the first step of the command line configuration. You may have to edit the system Git configuration too and I don’t have any idea where they hid that.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Randakar
  • 1,018
  • 1
  • 10
  • 10
  • 1
    "You may have to edit the system git configuration too". No, usually not. The system and user config are combined; setting the proxy in one of the two should be enough. – sleske Oct 09 '12 at 07:28
  • In my case it's located on my Windows machine in [git home]\etc\gitconfig - after editing it works like a charm! – Barmaley Oct 03 '13 at 04:28
  • This is especially useful if the command line doesn't like your password due to special characters. – Origin Oct 26 '16 at 09:42
22

If you are using Ubuntu, then do the following...

Step 1: Install Corkscrew

sudo apt-get install corkscrew

Step 2: Write a script named git-proxy.sh and add the following

#!/bin/sh

exec corkscrew <name of proxy server> <port> $*

# <name_of_proxy_server> and <port> are the ip address and port of the server
# e.g. exec corkscrew 192.168.0.1 808 $*

Step 3: Make the script executable

chmod +x git-proxy.sh

Step 4: Set up the proxy command for Git by setting the environment variable

export GIT_PROXY_COMMAND="/<path>/git-proxy.sh"

Now use the Git commands, such as

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sk Hasanujjaman
  • 321
  • 2
  • 2
17

There's something I noticed and want to share here:

git config --global http.proxy http://<proxy address>:<port number>

The method above will not work for SSH URLs (i.e., git@github.com:<user name>/<project name>.git):

git clone git@github.com:<user name>/<project name>.git // will not use the http proxy

And things will not change if we set SSH over the HTTPS port (https://help.github.com/en/articles/using-ssh-over-the-https-port) because it only changes the port (22 by default) the SSH connection connects to.

Elly
  • 49
  • 1
  • 1
  • 7
miáo
  • 303
  • 3
  • 9
16

Try to put the following in the ~/.gitconfig file:

[http]
    proxy = http://proxy:8080
[https]
    proxy = http://proxy:8080
[url "https://"]
    insteadOf = git://
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
augustocbx
  • 762
  • 8
  • 8
  • 1
    I tried all the stuff above. It wasn't until I added the https entry listed here that I was able to work. – Brent Fisher Oct 05 '18 at 20:06
  • What is it supposed to do? Why is this necessary? How does it work? An explanation would be in order. What is the idea/gist? From [the Help Center](https://stackoverflow.com/help/promotion): *"...always explain why the solution you're presenting is appropriate and how it works"*. Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/42402027/edit), not here in comments (but ****** ****** ****** ***without*** ****** ****** ****** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Mar 18 '23 at 19:03
16

Faced same issue because of multiple .gitconfig files in Windows, followed below steps to fix the same:

Step 1: Open Git Bash

Step 2: Look for .gitconfig, executing following command:

git config --list --global --show-origin

Step 3: Copy the below content in .gitconfig:

[http]
    proxy = http://YOUR_PROXY_USERNAME:YOUR_PROXY_PASSWORD@YOUR.PROXY.SERVER:YOUR.PROXY.SERVER.PORT
    sslverify = false
[https]
    proxy = http://YOUR_PROXY_USERNAME:YOUR_PROXY_PASSWORD@YOUR.PROXY.SERVER:YOUR.PROXY.SERVER.PORT
    sslverify = false
[url "http://github.com/"]
    insteadOf = git://github.com/

[user]
    name = Arpit Aggarwal
    email = aggarwalarpit.89@gmail.com
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
11

For the Git protocol (git://...), install socat and write a script such as:

#!/bin/sh

exec socat - socks4:your.company.com:$1:$2

Make it executable, put it in your path, and in your ~/.gitconfig set core.gitproxy to the name of that script.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ashutosh
  • 451
  • 4
  • 5
  • Works for windows with cygwin's SOCAT too. using `socat STDIO PROXY:%proxy%:%1:%2,proxyport=%PROXYPORT%` – davenpcj Apr 28 '16 at 16:20
  • 1
    Can use `set GIT_PROXY_COMMAND=path\to\script` to make GIT use the proxy without messing with git config. – davenpcj Apr 28 '16 at 16:22
  • Yes! Finally the right hint! I also needed authentication: exec socat STDIO PROXY::$1:$2,proxyport=,proxyauth=: Found here: https://gist.github.com/sit/49288 – Joachim Nov 06 '17 at 17:08
7

I work on Windows XP at work (state/government), so I did my research and found this here and it worked for me.

The http_proxy Environment Variable

If you use a proxy server or firewall, you may need to set the http_proxy environment variable in order to access some URL from the commandline.

Example: Installing PPM for Perl or applying an RPM file in Linux, updating Ubuntu

Set the http_proxy variable with the hostname or IP address of the proxy server:

http_proxy=http:// [proxy.example.org]

If the proxy server requires a user name and password, include them in the following form:

http_proxy=http:// [username:password@proxy.example.org]

If the proxy server uses a port other than 80, include the port number:

http_proxy=http:// [username:password@proxy.example.org:8080]

Windows XP

  1. Open the Control Panel and click the System icon.
  2. On the Advanced tab, click on Environment Variables.
  3. Click New in the System variables panel.
  4. Add http_proxy with the appropriate proxy information (see examples above).

Linux, Solaris or HP-UX

Set the http_proxy environment variable using the command specific to your shell (e.g., SET or export). To make this change persistent, add the command to the appropriate profile file for the shell. For example, in Bash, add a line like the following to your .bash_profile or .bashrc file:

  1. http_proxy=http:// [username:password@hostname:port];
  2. export $http_proxy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shak Daniel
  • 217
  • 4
  • 11
7

In addition of these answers, I found helpful to consider these two points:

One may need to enforce an authentication scheme:

[http]
    # https://github.com/git/git/blob/master/Documentation/config.txt
    proxyAuthMethod = anyauth|basic|digest|negotiate|ntlm

Also, typically with an NTLM authentication schema, one may need to provide the AD domain explicitly.

In Git Bash:

echo %userdomain%

And update the http.proxy accordingly:

git config --global http.proxy http://DOMAIN\\proxyuser:proxypwd@proxy.server.com:8080

Anyway, investigation may be helped by adding CURL logs:

export GIT_CURL_VERBOSE=1
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
blacelle
  • 2,199
  • 1
  • 19
  • 28
  • I needed to add proxyAuthMethod using `git config --global http.proxyAuthMethod basic`. Git gersion 2.8.3 didn't send in any authentication until I set this config parameter. – HeatfanJohn Jul 24 '18 at 20:14
6

If you have tsocks or proxychains installed and configured, you can do

tsocks git clone <your_repository>

or

proxychains git clone <your_repository>

To make it shorter, I created a symbolic link, /usr/bin/p, for proxychains, so I can use it like this

p git clone <your_repository>

And I can use it to proxy any command,

p <cmd-need-be-proxied>

By the way, proxychains has not been updated for a long time, and you may want to try proxychians-ng instead.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Fangxing
  • 5,716
  • 2
  • 49
  • 53
4

Setting the Git proxy in the terminal

If

  • you do not want set a proxy for each of your Git projects manually, one by one, and
  • always want to use same proxy for all your projects

Set it globally once:

git config --global http.proxy username:password@proxy_url:proxy_port
git config --global https.proxy username:password@proxy_url:proxy_port

If you want to set a proxy for only one Git project (there may be some situations where you may not want to use same proxy or any proxy at all for some Git connections):

// Go to the project root
cd /bla_bla/project_root
// Set proxy for both HTTP and HTTPS
git config http.proxy username:password@proxy_url:proxy_port
git config https.proxy username:password@proxy_url:proxy_port

If you want to display the current proxy settings:

git config --list

If you want to remove the proxy globally:

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

If you want to remove the proxy for only one Git root:

// Go to the project root
cd /bla-bla/project_root
git config --unset http.proxy
git config --unset https.proxy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Add080bbA
  • 1,818
  • 1
  • 18
  • 25
  • `https.proxy` is invalid config . Only the configuration item named `http.proxy` exists. see: https://git-scm.com/docs/git-config/2.9.5#Documentation/git-config.txt-httpproxy – ipcjs May 09 '22 at 12:20
3

Here is the proxy setting:

git config --global http.proxy http://<username>:<pass>@<ip>:<port>
git config --global https.proxy http://<username>:<pass>@<ip>:<port>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hannad rehman
  • 4,133
  • 3
  • 33
  • 55
3

I followed the most of the answers which was recommended here. First I got the following error:

fatal: unable to access 'https://github.com/folder/sample.git/': schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.

Then I have tried the following command by @Salim Hamidi

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

But I got the following error:

fatal: unable to access 'https://github.com/folder/sample.git/': Received HTTP code 407 from proxy after CONNECT

This could happen if the proxy server can't verify the SSL certificate. So we want to make sure that the ssl verification is off (not recommended for non trusted sites), so I have done the following steps which was recommended by @Arpit but with slight changes:

1.First make sure to remove any previous proxy settings:

git config --global --unset http.proxy

2.Then list and get the gitconfig content

git config --list --show-origin

3.Last update the content of the gitconfig file as below:

[http]
sslCAInfo = C:/yourfolder/AppData/Local/Programs/Git/mingw64/ssl/certs/ca-bundle.crt
sslBackend = schannel
proxy = http://proxyuser:proxypwd@proxy.server.com:8080
sslverify = false
[https]
proxy = http://proxyuser:proxypwd@proxy.server.com:8080
sslverify = false
Wael Almadhoun
  • 401
  • 4
  • 7
3

I have tried all the previous answers and nothing worked for me, as there was a proxy password encoding issues.

This command worked:

git config --global http.proxy http://username@proxy.example.com:PortNumber

Do not enter the password in your command. It will dynamically ask for when you try to connect to any Git repository.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ishtdeep Hora
  • 310
  • 2
  • 4
2

For Windows users: if git config or set http_proxy= doesn't work, this answer may help:

Replace the git:// protocol of the Git repository with http://. Note, you'll have to set the http_proxy first, anyway.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DomTomCat
  • 8,189
  • 1
  • 49
  • 64
1

After tirelessly trying every solution on this page, my workaround was to use an SSH key instead!

  1. Open Git Bash
  2. ssh-keygen.exe -t rsa -C <Your username>
  3. Open your Git provider (GitHub, Bitbucket, etc.)
  4. Add copy the id_rsa.pub file contents into Git provider's input page (check your profile)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Janac Meena
  • 3,203
  • 35
  • 32
1

To change https.proxy config for a single repository (not global git config) before a new clone (you can not change repo git config before repository exists)

cd /path/to/new/clone/
git init .
git config http.proxy http://...myProxy.com:myPort
git config https.proxy https://...myProxy.com:myPort
git remote add origin https://github.com/opencv/opencv.git
git fetch origin
git checkout -b master --track origin/master

Note: I needed https.proxy (not http.proxy) to have it working.

Note: you can find your proxy settings on Windows 10 at Settings -> Network&Internet -> Proxy -> Address + Port

Vladislav Povorozniuc
  • 2,149
  • 25
  • 26
0

An alternative to using a proxy is to use SSH

In the Git configurations, configure the origin remote on the SSH address. Then use the ssh-keygen command, which gives you a public key that you can set in your GitLab or Gitab account settings and login accordingly done...

  1. Verify which remotes are using by running git remote -v in your Git client.

  2. If this is http(s) URL, changed it to ssh address , run: git remote set-url <remote name, e.g. origin> <new SSH URL>. For example,

     git remote set-url git@gitlab.com:example/myproject.git
    
  3. To generate SSH key for login, run: ssh-keygen -o. This command generate public (id_rsa.pub file) and private keys.

  4. Copy public key contents. (from id_rsa.pub file)

  5. Go to GitLab, GitHub, etc. profile section → setting/ssh-key. Create a new SSH key and paste the public key contents

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fatemeh sadeghi
  • 1,757
  • 1
  • 11
  • 14