进入新环境,接手前人留下的电脑,使用的源代码管理工具是git
,远程仓库是gitee
,git clone https://xxx.git
remote:You do not have permission to pull from the repository via HTTPS
大概是因为前人离职了,账号被移除了。windows下可以去控制面板-用户账户-凭据管理器-git:https://gitee.com
,修改相关的用户名与密码。
HTTPS
:使用https
到git Bash
里使用clone
命令,但是每次fetch
和push
代码都需要输入账号和密码,这也是https方式的麻烦之处。SSH
:安全外壳协议,很多安全终端模拟软件都是使用的SSH协议登录远程服务,例如xshell
,直接使用用户名,密码就能登录远程服务(网络连通的情况下),这也是SSH其中一种安全验证(基于口令),另外一种安全验证是基于密钥,git便是采用的这种方式与远程仓库进行交互。git config --global user.name "randyfield"
git config --global user.email "xx@qq.com"
ssh-keygen -t rsa -C "xx@qq.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Admin/.ssh/id_rsa):
Created directory '/c/Users/Admin/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Admin/.ssh/id_rsa
Your public key has been saved in /c/Users/Admin/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Yva7uIuSpHF7P6bfvQDTA3pqu3Vi8Y2fhXlTTQliEA8 xx@qq.com
The key's randomart image is:
+---[RSA 3072]----+
| Eoo . |
| + . . .|
| . . ..|
| . o o |
| . O S . .|
|. o = B + o . |
| = oo + * + + |
|. +..=o= = + . |
| o=**++.=. |
+----[SHA256]-----+
/c/Users/用户名/.ssh/id_rsa
在C盘的路径
C:\Users\Admin\.ssh
id_rsa.pub
文件,里面就是公钥,复制设置-SSH公钥