Git with Proxy
1. Problem Description
When you enable a proxy, you can visit GitHub but your git operation
like git push failed. Some info reminds you:
1 | ssh: connect to host github.com port 22: Connection refused |
This means, you enabled the proxy, but the git, didn’t connect network with proxy.
2. How to Solve
To solve the problem, we need configure the git:
Assume your proxy software’s port is 7897.
Enable Git’s proxy:
1 | git config --global http.proxy http://127.0.0.1:7897 |
[!NOTE]
Here, the
https.proxyalso connect to thehttp portprovided by proxy software.
You can check the proxy states:
1 | git config --global --get http.proxy |
Operate Git Commands like git push…
[!NOTE]
If your proxy isn’t always enabled, you may should disable the git proxy after the system proxy disabled.
1
2 git config --global --unset http.proxy
git config --global --unset https.proxy