Git 使用代理
Lynch Lee BIG_BOSS

多亏了伟大的防火墙,Git push 一直都不太稳定,如果出现 Failed to connect to github.com port 443: Timed out 超时报错,一般通过设置代理或者取消代理并再次 push 以尝试是否能绕过长城,具体操作如下:

查看当前代理

1
2
git config --global http.proxy
git config --global https.proxy

使用 socks5

1
2
3
4
5
6
7
git config --global http.proxy 'socks5://127.0.0.1:$your_port'
git config --global https.proxy 'socks5://127.0.0.1:$your_port'

git config http.proxy 'socks5://127.0.0.1:$your_port'
git config https.proxy 'socks5://127.0.0.1:$your_port'

git push origin $your_branch #try to push

使用 http/https

1
2
3
4
5
6
7
git config --global http.proxy 'http://127.0.0.1:$your_port'
git config --global https.proxy 'https://127.0.0.1:$your_port'

git config http.proxy 'http://127.0.0.1:$your_port'
git config https.proxy 'https://127.0.0.1:$your_port'

git push origin $your_branch #try to push

取消代理,有时候可能直连才能 push,感谢万能的防火墙带来的坑

1
2
3
4
5
6
7
git config --global --unset http.proxy
git config --global --unset https.proxy

git config --unset https.proxy
git config --unset https.proxy

git push origin $your_branch #try to push
  • Post title:Git 使用代理
  • Post author:Lynch Lee
  • Create time:2021-04-21 14:39:55
  • Post link:https://neeomaclynch.github.io/2021/04/21/Git-使用代理/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments