github在同步本地与远程仓库时遇到的问题
Q1.生成密钥对
现在大多数windows系统已经默认下载了OpenSSH,所以直接在git bash中生成ssh密钥即可
如果不能正常生成,设置->系统->可选功能->添加功能->添加OpenSSH应用
Q2. remote origin already exists.
解决方法
Q3.connect to host github.com port 22: Connection refused
笨人直接采用改端口的方法请移步
结果报错
$ ssh -T git@github.com
/c/Users/shenqiuyu/.ssh/config line 1: no argument after keyword "\377\376h"
/c/Users/shenqiuyu/.ssh/config: terminating, 1 bad configuration options
确保文件是以 ASCII 或 UTF-8 编码保存的。如果您使用的是 Windows 系统,一些文本编辑器(如 Notepad++)允许您查看和更改文件的编码。---文心一言
避免使用windows的自带文本编辑器!别忘了,我们的好朋友vscode编!辑!器!
Q4.error: src refspec master does not match any error: failed to push some refs to ‘github.com:github
说,我的master分支与origin仓库的分支不匹配
well,ok,fine
我改我改
git branch -M main
git push origin main
结论就是,珍惜每一次报错提示,多方搜索,而不是像笔者一样,反复回头重试已经行不通的路。