本地git连接github记录

1v7w / 2023-08-21 / 原文

首先需要有一个能正常上去github的代理,然后去配置git走代理就ok。

http部分

假设代理的http端口为7890,那么执行以下命令会在~/.gitconfig中多出配置。

git config --global http.https://github.com.proxy http://127.0.0.1:7890

ssh部分

如果除了clone公开项目以外,还要搞其他东西,比如push、pull等,就需要走ssh。

~/.ssh/config文件中加入以下部分

Host github.com
    User git
    Port 443
    Hostname ssh.github.com
    TCPKeepAlive yes
    ProxyCommand connect -S 127.0.0.1:7890 -a none %h %p