git基础-(7)-使用SSH登录github仓库

一、新建 SSH 的密钥

运行命令生成.ssh 密钥目录
$ ssh-keygen -t rsa -C [email protected]

打开用户根目录的 .ssh文件夹,查找里面的公钥文件:选中并复制

二、 SSH 的密钥

打开github账号的setting设置,找到  SSH and GPG keys 并将 步骤一中的 公钥信息,复制到 SSH keys 栏目中。

三、获取SSH连接

1、在仓库的下载中,Clone or download–>Use SSH–> Clone with SSH 获得项目仓库的 SSH链接。

2、在本地客户端中,添加远程仓库的SSH连接别名:

cooldeMacBook-Pro:git-learn cool$ git remote add origin_ssh [email protected]:sky123/huashan.git

3、执行提交到远程库操作

cooldeMacBook-Pro:git-learn cool$ git push origin_ssh master
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 848 bytes | 848.00 KiB/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local object.
To github.com:sky123/huashan.git
   e416c03..a4fe921  master -> master
cooldeMacBook-Pro:git-learn cool$ 

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments