Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is git push through network working? (proxy)

Tags:

git

proxy

I'm wondering how git push works. I'm behind a proxy and even configuring it in my PhpStorm soft doesn't work.

So, I'm wondering how it is sent trough network, I guess using the port 80 for HTTP and 443 for HTTPS.

I read a bunch of threads on SO but couldn't figure out what's wrong there. I guess "my" proxy doesn't have WebDAV enabled as explained here: Can't push to github through proxy

But I would like to know if anything else could be the source of the issue here, knowing that all ports are closed, excepted 80, 22 and 443.

git remote -vv
origin  https://[email protected]/Vadorequest/vadorequest.git (fetch)
origin  https://[email protected]/Vadorequest/vadorequest.git (push)

Solution:

Not secured proxy (http)

If the proxy is not secure then you can configure it using:

git config --global http.proxy http://user:password@host:port

And disable it using:

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

Secured proxy (https)

git config --global https.proxy https://user:password@host:port

And disable it using:

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

Note that if you are under Windows and using TortoiseGit, you can set the proxy settings from the software itself. (Network tab)

If you're using Cygwin then be aware that if you set the global config it will be set only for the current environment. (Using cmd.exe will set it for Windows, but using the cygwin console will set it for cygwin only)

So, if you're using Git through an IDE (PhpStorm, WebStorm) be sure to have set the config in the environment used by the IDE, or it will not work.

Be also aware that if you have set the proxy in git setting and you're not behind the proxy, it will not work neither. (i.e: You've set it at work and it works fine, but when you're using it at home it doesn't work anymore while it used to work before)

like image 453
Vadorequest Avatar asked Oct 13 '14 11:10

Vadorequest


People also ask

How do I git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT.

How does git push?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.

How set no proxy git bash?

bash_profile file in your user root directory, then manually create it. You can do same in Windows. Add an environment variable 'no_proxy' with value of URLS_to_Ignore.


3 Answers

If your proxy allow access without user and password, then you can use:

git config --global https.proxy https://proxy.company.com:8888

If your proxy need user & password then:

git config --global https.proxy https://user:[email protected]:8888

Be sure to replace 8888 with your real proxy port.
Be sure to replace proxy.company.com with your real proxy server name or IP address.

Tell me if this helps.

like image 61
Antoan Milkov Avatar answered Oct 20 '22 16:10

Antoan Milkov


If you're behind an ntlm proxy where you need to specify domain, username and password I suggest using cntlm. You just need to configure cntlm with the proxy credentials then use localhost:3128 in the git config command.

like image 41
Silvio Avatar answered Oct 20 '22 17:10

Silvio


To avoid each time using below command for different repositories :

git config --global https.proxy https://proxy.company.com:8888

set the environnementale variable as below and chill :

export https_proxy=https://username:password@proxy_ip:port
like image 1
ross Avatar answered Oct 20 '22 16:10

ross