本文章总共讲述以下几点内容:
- git SSH 协议的配置
- 利用git ssh协议链接远程仓库
一:git SSH 协议的配置
- 首先我们先在本机上生成ssh协议的公匙和私匙
执行过程一直enter
即可
ssh-keygen -t rsa -C '在github上注册的邮箱地址'

- 可以查看公匙和私匙所在位置

-
公匙需要配置到GitHub上
我们复制id_rsa.pub的内容放到gitbub上,安装过程如下:
1:找到settings.png
2:进入ssh.png
3:image.png
4:配置ssh.png
5:复制公匙的内容.png
6:生成公匙.png
生成公匙成功.png
二:利用git ssh协议链接远程仓库
假设已经在远程仓库建立了一个仓库,需要将本地的仓库推送上去
配置 连接远程仓库
git remote -v // 查看当前连接的远程仓库

删除相关配置,重新开始配置
git remote rm origin // 删除远程仓库配置
git remote add origin git@github.com:登录用户名/仓库名

到这里我们就可以推送我的本地仓库的内容到github上托管起来了,注意第一次建立连接的时候,需要进行确定,直接yes
就好,并且会将配置的相关信息写入known_hosts,后续再进行推送,就不需要再次确认了,SSH链接已经配置了好了。


进行完第一次链接之后,图中的钥匙图案变成了绿色。

网友评论