添加HTTPS和SSH连接

This commit is contained in:
MI-Air 2022-06-05 00:47:40 +08:00
parent 86dc58dd7a
commit e78a63a61e
7 changed files with 49 additions and 1 deletions

View File

@ -1,4 +1,4 @@
## git 版本库初始化与文件提交操作
## 一、git 版本库初始化与文件提交操作
### 1. 初始化 git 仓库
```
@ -29,3 +29,51 @@ git commit -m 'git版本库初始化与文件提交操作'
git log
```
![](git01_files/2.jpg)
## 二、使用 Https 推送至远程仓库
### 1. 新建远程仓库
![](git01_files/3.jpg)
### 2. 将建立好的本地库绑定并推送至远程仓库
```
git remote add origin https://git.chenguanzhou.com/xhong/git-study-md.git
git push -u origin master
```
![推送成功](git01_files/4.jpg)
## 三、使用 SSH 加密推送
### 1. 本地生成 SSH 公钥和秘钥
```
ssh-keygen -t rsa -C "远程仓库的邮箱地址"
```
![生成公钥&秘钥](git01_files/5.jpg)
### 2. 查看生成的公钥 & 秘钥
> 文件位置:用户 > 本机用户名 > .ssh文件夹
```
第一个是密钥,第二个是公钥(*.pub)
```
![](git01_files/6.jpg)
> 用记事本打开生成的 SSH 公钥
### 3. 远程绑定 SSH 公钥
> 添加密钥
![](git01_files/7.jpg)
> 查看密钥
![](git01_files/8.jpg)
> 检查测试链接
```
ssh -T git@git.chenguanzhou.com
```
### 4. 将建立好的本地库绑定并推送至远程仓库
```
git remote add origin git@git.chenguanzhou.com:xhong/git-study-md.git
git push -u origin master
```

BIN
git01_files/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
git01_files/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
git01_files/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
git01_files/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
git01_files/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
git01_files/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB