How to use git behind proxy on Ubuntu

If you would like to use git behind proxy, you can configure proxy settings via a following git-specific way. Note that setting http_proxy environment variable alone is not sufficient since the variable is ignored by git. You need to store proxy information in a git configuration file by using the following command.

$ export http_proxy=http://myproxy.domain.com:1234
$ git config --global http.proxy $http_proxy

Then, a user-specific git configuration file (~/.gitconfig) will be created and updated as follows.

[http]
proxy = http://myproxy.domain.com:1234

If you are using Ubuntu 11.04 or 11.10, you may be getting the following error when trying to clone any repository via https from github:

remote HEAD refers to nonexistent ref, unable to checkout

The error is due to a bug in the libcurl version installed in the particular version of Ubuntu you are using. To solve the problem, manually install the latest libcurl3-gnutls, and two dependencies from:

$ sudo dpkg -i libp11-kit0_0.10-1_amd64.deb libgnutls26_2.12.14-5ubuntu2_amd64.deb libcurl3-gnutls_7.22.0-3ubuntu2_amd64.deb

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *