18

Where do I configure the proxy settings for GIT in IntelliJ Idea? I've gotten the proxy settings working for the plugins, but I just can't find it for GIT; and the help files only mention subversion.

Any help is appreciated.

carlspring
  • 31,231
  • 29
  • 115
  • 197
maximus
  • 2,417
  • 5
  • 40
  • 56

3 Answers3

44

You have to configure proxy for git and not for intelliJ, intelliJ will just call the git command line.

git config --global http.proxy yourProxy:port should do it.

carlspring
  • 31,231
  • 29
  • 115
  • 197
Colin Hebert
  • 91,525
  • 15
  • 160
  • 151
  • On my case i had to add one additional step to make it work -> On Intellij -> Preferences -> Search git -> choose git -> ssh executable -> to native. Instead of the built in. This cause the bitbucket is using ssh. – cabaji99 Oct 19 '17 at 17:02
  • 1
    After adding the proxy using `git config --global http.proxy http://username:password@host:port` my clone attempt failed due to the self-signed certificate presented by the proxy. This answer provided the solution to the certificate error: https://stackoverflow.com/a/11622001/669645 – Edd Aug 25 '21 at 11:58
3

To be complete I would like to add how to hop over a proxy to get to git server or secured sites using ssh, like for example private github repositories.

For intellij when using this option, you must select to use the native ssh implementation in Project Settings --> Version Control --> VCSs --> Git --> SSH Executable

We use a tool called corkscrew. This is available for both CygWin (through setup from the cygwin homepage) and Linux using your favorite packaging tool.

For MacOSX I refer to this blogpost to install it on you Mac.

The command line is as follows :

corkscrew <proxyhost> <proxyport> <targethost> <targetport> <authfile>

The proxyhost and proxyport are the coordinates of the https proxy.

The targethost and targetport is the location of the host to tunnel to.

The authfile is a textfile with 1 line containing your proxy server username/password separated by a colon

e.g:

abc:very_secret

Installation for using git:// protocol : usually not needed!

  • Create a helper script to create the tunnel

Create a script ~/bin/gitproxy which contains :

#!/bin/bash
corkscrew proxy.colo.elex.be 3128 github.com 9148 ~/.ssh/proxy_auth 
  • Create the proxy_auth file in the ~/.ssh/ folder

Make sure it is safe from prying eyes.

  • Set an environment variable to define the proxy command for git

    $ export GIT_PROXY_COMMAND=/home/pti/bin/gitproxy

You might place this in a section or script sourced from .bashrc which dynamically detects if you are behind the proxy or not. If the variable is not defined then git will work as usual.

  • test it

Installation for using "normal" ssh protocol for git communication By adding this to the ~/.ssh/config this trick can be used for normal ssh connections

Host gitproxy HostName github.com Port 22 ProxyCommand corkscrew %h %p ~/.ssh/proxy_auth

enjoy!

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
1

In my case i had to set proxy through MSDOS command line, then it pushed results without 407 error

SET HTTP_PROXY=http://user:passs@proxydomain.com:portnumber
Sultanos
  • 463
  • 7
  • 12
  • Be aware that reboot will erase this conf , therefore if you want to set it for ever, you should add it to system variables menu . Here is a link for this settings procedure for windows. https://www.computerhope.com/issues/ch000549.htm – Sultanos Nov 26 '18 at 09:27