17

New to working with git in Windows. I downloaded the GitHub Desktop application and can connect my account, but doing pushes/pulls fails because of an unresolved host. Asking around the workplace I got the following suggestion to type this command into the git shell.

git config --global http.proxy http://username:password@proxy.workplace.com:8080

Does this:

  1. Store my password in plain text?
  2. Send my password in plain text?

Doesn't GitHub for Desktop generate and use SSH keys instead (I got an email notification when I first connected my account)? How can I configure GitHub Desktop to work with this proxy?

raphael
  • 2,762
  • 5
  • 26
  • 55
  • Similar to http://stackoverflow.com/questions/16153450/github-windows-client-behind-proxy but there's no answer for GitHub Desktop, and ssh specifically – raphael Jul 27 '16 at 14:01

4 Answers4

42

To directly add a proxy to Github Desktop without using git shell:

  1. Set up/Sign in to your account in Github Desktop(This won't be a problem, proxy only doesn't allow you to Add, create or clone repo)

  2. Close Github Desktop for the time being(to set up proxy).

  3. Go to C:\Users\@yourusername.

  4. There you will find a file named .gitconfig

  5. Open it with any text editor(I have used sublime text 3) and add

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

and save.

  1. Now you can add, create and clone repos in Github Desktop.

Note(for TFS users): TFS will return 502 bad gateway error when you use the above proxy configuration. Use hash # to comment out the proxy config in .gitconfig to switch between Git and TFS.

Sayan Mandal
  • 605
  • 5
  • 9
  • 1
    I'm running Studio 2017 / TFS with a git Project and my company uses a proxy for all web connections. Downloaded GitHub Desktop, added the [http] section to the .gitconfig and I was able to successfully clone a repository from a GitHub.com url. – John Dyer Jul 10 '19 at 18:02
  • If you need this proxy setup for githib.com access AND you also access a local TFS repository then you'll need to switch this config in and out depending. TFS will return 502 errors when the proxy config exists. Use hash char # to comment out in the .gitconfig file as needed. – John Dyer Jul 11 '19 at 20:07
  • Thanks @JohnDyer for letting me know. I have not used TFS before! I will add this for a TFS user just in case. – Sayan Mandal Jul 20 '19 at 15:50
21

So actually the solution was to type this command into the git shell.

git config --global http.proxy http://<proxy-ip>:<proxy-port>
Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
raphael
  • 2,762
  • 5
  • 26
  • 55
  • 1
    I was having an issue with proxy settings and github desktop - found out via the debug log that it was using its own git.exe not the one in my PATH env var. I had to run the above command using the fully qualified path for that specific exe - C:\Users\user.nam\AppData\Local\GitHub\PortableGit_f02737a78695063deace08e96d5042710d3e32db\cmd\git.exe – leinad13 May 02 '17 at 13:22
2

Try and upgrade to GitHub Desktop 2.4 (March 2020)

Working behind a proxy

With GitHub Desktop 2.4, we automatically handle setup without needing you to configure anything manually—worry no more!

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 4
    Ah, nope. I installed 2.4.3 (over an existing install from Nov 2019) and still get "fatal: unable to access 'https://github.com.....' : Received HTTP code 407 from proxy after CONNECT" Unfortunately when no background is given about how you magically handle proxy, then it doesn't help in troubleshooting. I'm on Windows 10 and I have no problem connecting via command line with git config credential.helper=wincred – Jason S May 04 '20 at 22:50
  • @JasonS wincred? What version of Git for Windows are you using? It should be "manager". – VonC May 05 '20 at 05:10
  • 2.23.0.windows.1 – Jason S May 05 '20 at 06:11
  • @JasonS Can you check with 2.26.2 (although I believ GitHub Desktop might use its own embedded Git distribution) – VonC May 05 '20 at 06:35
1

It might work with this:

  • git config --global http.proxy proxy_address:proxy_port
  • git config --global https.proxy proxy_address:proxy_port

If username and password are not that much important then use:

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