There are many ways to use git with a proxy server, but for now I'll only explain how to use it using http/https and ssh protocols.
Let's see how to use git with a proxy!
Basically it works with any other proxy tool, just adjust proxycommand
attribute according to proxy tool you are using with.
In this case, I'm gonna using socat
.
socat
stands for SOcket CAT, it's a utility for data transfer between two addresses.
-
Install
socat
using your Distro's package manager. -
Create or add the following line into
~/.ssh/config
:host github.com hostname ssh.github.com port 443 user git proxycommand socat - PROXY:<host>:%h:%p, proxyport=<port>
-
Replace
<host>
and<port>
with your proxy settings. -
If your proxy need authentication, add
proxyauth=<username>:<password>
afterproxyport
. Separated by comma,
.proxycommand socat - PROXY:<host>:%h:%p, proxyport=<port>, proxyauth=<username>:<password>
git clone [email protected]:username/repo.git
-
Add the following line into
~/.gitconfig
:[http] [http "https://github.com"] proxy = http://<username>:<password>@<host>:<port> sslVerify = false
-
Replace
<username>
,<password>
,<host>
and<port>
according to your proxy settings. -
If your proxy doesn't need authentication, just remove the
<username>
and<password>
.proxy = http://<hostname>:<port>
git clone https://github.com/username/repo.git