github 客户端设置

admin 2024年3月18日17:22:30评论3 views字数 1206阅读4分1秒阅读模式

github 在 clone 源码时有两种协议可用,分别是 SSH 协议和 HTTPS 协议,SSH 协议会使用 22 端口,HTTPS 协议使用的是 443 端口。

例如:

github 客户端设置

git@github.com:hyang0/ip_notes.git

如果 SSH 协议在使用中抽风,可以试试将 22 端口换成以下配置。可以在 ~/.ssh/config 中更换 SSH 端口:

Host github.com    Hostname ssh.github.com    Port 443    User git

这里使用 443 代替原 22 端口,在执行 git clone 、git push 时仍然可以使用 ssh 协议。git clone 项目时,使用的还是 ssh 协议:

git clone git@github.com:hyang0/ip_notes.git

github 客户端设置

这种方式是没有使用代理的,使用的是原生 SSH 协议,如果需要使用代理,可以对 ~/.ssh/config 做如下改动:

Host github.com    HostName github.com    User git    ProxyCommand connect -S 127.0.0.1:1080 %h %p

类似的配置有:

Host github.com    User git    ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
Host github.com    User git    Hostname ssh.github.com    PreferredAuthentications publickey    IdentityFile ~/.ssh/id_rsa    Port 22    ProxyCommand connect -S 127.0.0.1:7890 %h %p

-S 表示使用socks5代理,如果是http代理则为-H。connect 工具是 windows 下的 git 自带的, 一般在 /mingw64/bin/connect 下面。

$ which connect/mingw64/bin/connect$

如果不想使用 SSH 配置,也可以直接使用 HTTPS 协议。在 git-bash 下设置 http_proxy, https_proxy 即可:

# ~/.bashrcfunction proxy{    export http_proxy=http://127.0.0.1:7890    export https_proxy=http://127.0.0.1:7890}function unproxy{    unset http_proxy    unset https_proxy}

使用时执行 proxy ,取消时执行 unproxy

参考

https://gist.github.com/laispace/666dd7b27e9116faece6https://blog.csdn.net/omaidb/article/details/118104908

全文完。

如果转发本文,文末务必注明:“转自微信公众号:生有可恋”。

原文始发于微信公众号(生有可恋):github 客户端设置

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年3月18日17:22:30
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   github 客户端设置https://cn-sec.com/archives/2585085.html

发表评论

匿名网友 填写信息