设置SSH Keys公钥
- 在git中配置名称和邮箱确认身份
git config --global user.name "用户名"
git config --global user.email "email"
- 在git中查看配置的名称和邮箱
git config --global user.name
git config --global user.email
- 在git中查看配置公钥的命令
1、ssh-keygen -t rsa -C “你的邮箱名”,代码如下
2、出现输入等待 、直接按回车(enter),则ssh keys生成后存放的路 径为C:\User\用户名.ssh)
3、输入密码: 123456(此处可以不用设置密码直接按回车(enter))
4、确认密码: 123456(此处可以不用设置密码直接按回车(enter))
ssh-keygen -t rsa -C "你的email"
- ssh keys与github账号绑定
在C:\User\用户名.ssh目录下找到 id_rsa.pub 文件(公用密钥)id_rsa(私用密钥)如下图
将id_rsa.pub 中的所有信息拷贝到 Github 中的SSH Keys中 打开Github 右上角 如下图
Title 框内随便写
添加文件到github
克隆远程仓库
git clone https://github.com/dhn111/Qt.git
添加文件夹下所有文件到暂存区 git add .
git add .
把文件提交到仓库 git-commit -m “”
git commit -m ' '
删除一个 remote
git remote rm origin
关联远程仓库 (第一次使用需要添加github公钥)
git remote add origin git@github.com:****/Qt.git
把本地内容推送到远程库 使用 git-push 这里是推送到main分支下
git push -u origin main
删除github中的文件
拉取Github仓库 master(根据自己仓库的名字写)
git pull origin master
删除Github中的文件 qt (根据自己想要删除的文件)
git rm -r --cached qt
提交删除说明
git commit -m '删除了trash'
更新Github远程仓库 master(根据自己仓库的名字写)
git push -u origin master
问题描述
新生成密钥的时候,git clone或者git push的时候,经常会报这样的错误:
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
原因是少了一个known_hosts文件。本来密钥文件应该是三个,现在是两个,所以报了这样的错误。
此时选择yes回车之后即可,同时生成了缺少了的known_hosts文件:
Are you sure you want to continue connecting (yes/no)? //输入yes,回车
如下图所示:
总结
待更…