Note: while the use-case described is about using submodules within a project, the same applies to a normal git clone
of a repository over HTTP.
I have
The below method works for me:
echo 'export http_proxy=http://username:password@roxy_host:port/' >> ~/.bash_profile
echo 'export https_proxy=http://username:password@roxy_host:port' >> ~/.bash_profile
For me what it worked was:
sudo apt-get install socat
Create a file inside your $BIN_PATH/gitproxy with:
#!/bin/sh
_proxy=192.168.192.1
_proxyport=3128
exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
Dont forget to give it execution permissions
chmod a+x gitproxy
Run following commands to setup environment:
export PATH=$BIN_PATH:$PATH
git config --global core.gitproxy gitproxy
Use proxychains
proxychains git pull ...
update: proxychains is discontinued, use proxychains-ng instead.
This is an old question but if you are on Windows, consider setting HTTPS_PROXY as well if you are retrieving via an https URL. Worked for me!
I find neither http.proxy
nor GIT_PROXY_COMMAND
work for my authenticated http proxy. The proxy is not triggered in either way. But I find a way to work around this.
Create a authfile. The format for authfile
is: user_name:password
, and user_name
, password
is your username and password to access your proxy. To create such a file, simply run command like this: echo "username:password" > ~/.ssh/authfile
.
Edit ~/.ssh/config
, and make sure its permission is 644
: chmod 644 ~/.ssh/config
Take github.com as an example, add the following lines to ~/.ssh/config
:
Host github.com
HostName github.com
ProxyCommand /usr/local/bin/corkscrew <your.proxy> <proxy port> %h %p <path/to/authfile>
User git
Now whenever you do anything with git@github.com
, it will use the proxy automatically. You can easily do the same thing to Bitbucket as well.
This is not so elegant as other approaches, but it works like a charm.
as @user2188765 has already pointed out, try replacing the git://
protocol of the repository with http[s]://
. See also this answer