通过ssh的方式提交github - 重要文章!!vscode提交github

原因:
github的https的clone项目报错,所以改用ssh的方式

[非常重要] 通过ssh的方式提交github_git

1 本地创建ssh秘钥

目录是 .ssh 我电脑的目录在 C:\Users\Reciter\.ssh 生成秘钥文件 id_rsa id_rsa.pub

ssh-keygen -t -rsa -C 'second@mail.com'

id_rsa 就是你的秘钥
id_rsa.pub 就是你的公钥,将公钥的内容传到github上即可

2 SSH端口被防火墙屏蔽问题解决

创建config文件

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

3 github添加公钥

https://github.com/settings/keys

[非常重要] 通过ssh的方式提交github_项目报错_02

[非常重要] 通过ssh的方式提交github_github_03

4 本地拉取仓库代码

访问自己的代码库 https://github.com/pengchenggang/vuejsdev-com-github

[非常重要] 通过ssh的方式提交github_项目报错_04

开个git bash 输入命令

git clone git@github.com:pengchenggang/vuejsdev-com-github.git

5 git 设置代理(这个最后没用,不用这个)

git config --global http.proxy 'socks5://127.0.0.1:50944'
git config --global https.proxy 'socks5://127.0.0.1:50944'

git config --global https.proxy "socks5://ip:1080"

> socks
git config --global http.proxy 'socks5://127.0.0.1:50944' 
git config --global https.proxy 'socks5://127.0.0.1:50944'
> http
git config --global http.proxy http://127.0.0.1:1080 
git config --global https.proxy https://127.0.0.1:1080

> 只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080

> 取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

> 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

挂代理提交不上去 -这个很重要

> git push origin main:main
Connection reset by 20.205.243.160 port 443
fatal: Could not read from remote repository.

本地提交后,用命令提交 git push 然后 yes,就提交上去了。(挂代理的情况下)

经过测试,再次自动化提交的时候,就能提交了。

[非常重要] 通过ssh的方式提交github_项目报错_05

完成

[非常重要] 通过ssh的方式提交github_github_06

最后发布地址:https://pengchenggang.github.io/vuejsdev-com-github

参考文档

git中https和SSH的clone方式详细介绍 以及多个github账号的SSH冲突解决 以及SSH端口被防火墙屏蔽问题解决 通过HTTPS克隆私有项目问题

---------------------------------------------
生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
↑面的话,越看越不痛快,应该这么说:

生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!