How to get git to work through a proxy and IntelliJ Idea?

后端 未结 3 821
醉梦人生
醉梦人生 2021-01-01 23:45

Where to 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 fi

相关标签:
3条回答
  • 2021-01-02 00:25

    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!

    0 讨论(0)
  • 2021-01-02 00:26

    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
    
    0 讨论(0)
  • 2021-01-02 00:32

    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 shoud do it.

    0 讨论(0)
提交回复
热议问题