您好,欢迎来到外链网!
当前位置:外链网 » 站长资讯 » 专业问答 » 文章详细 订阅RssFeed

Git HTTP和SSH 代理配置

来源:互联网 浏览:125次 时间:2023-04-08

国内得gitee网速还好,pull push 一般都很快,但是github连接就非常不稳定。网上有很多教程,很少有靠谱的,自己尝试了一番总结出来的。

两种方式 http/httpsssh 两种方式得区别 clone: 使用ssh方式时,需要配置个人的ssh key,并将生成的ssh公钥配置到git服务器中。对于使用https方式来讲,就没有这些要求。push: 在使用ssh方式时,是不需要验证用户名和密码,如果你在配置ssh key时设置了密码,则需要验证密码。而对于使用https方式来讲,每次push都需要验证用户名和密码。

个人推荐使用ssh方式连接到GitHub感觉安全系数会高一些,而且还可以管理多个GitHub账户,可以参考一下方式进行配置。

git使用ssh方式连接github,gitee,可管理多个git账户
https://blog.csdn.net/y1534414425/article/details/109758866

设置代理 http/https # HTTP 代理git config --global http.proxy http://127.0.0.1:1080git config --global https.proxy http://127.0.0.1:1080# Socks5 代理git config --global http.proxy socks5://127.0.0.1:1080git config --global https.proxy socks5://127.0.0.1:1080

注意这里的 socks5 仅仅是代理使用的协议,它依然是针对 http 设置的,所以仅对 http 协议的仓库有效。使用 git@xxx 这种 ssh 连接的不会使用代理。

也可以分域名设置代理:

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

SSH 代理需要在密钥目录 (~/.ssh) (Windows 下是 C:\Users\{UserName}\.ssh) 新建一个 config 文件,没有后缀名。

Windows -S 为 socks, -H 为 HTTPProxyCommand connect -S 127.0.0.1:1080 %h %p

如果找不到 connect 命令那么指定其绝对路径,一般在 git 安装目录下 \mingw64\bin\connect.exe

也可以分域名代理:

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

所有的前提是你要有一个代理,且看个人手段,这里手动滑稽!

22254793