作者:平平您好 | 来源:互联网 | 2023-09-23 20:17
首先下载安装git:https:git-scm.comdownloads一路默认,安装完成后,打开文件夹C:\Users\Administrator\.ssh(Administrator是
首先下载安装git:https://git-scm.com/downloads/
一路默认,安装完成后,打开文件夹C:\Users\Administrator\.ssh(Administrator是当前用户名),在空白处点鼠标右键选择“Git Bush Here” ,打开gitbush。
配置用户名和邮箱:
$ git config --global user.name "your_name"
$ git config --global user.email "your_email@example.com"
生成密钥对:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
此时文件夹中会生成两个密钥文件:
![](https://img.php1.cn/3cd4a/1eebe/cd5/a1be7872e8d4934f.webp)
打开id_rsa.pub,将文件内容全选复制,准备粘贴到github上:
![](https://img.php1.cn/3cd4a/1eebe/cd5/a5d7215df572c386.webp)
登陆github,点击右上角头像,选择Settings,选择SSH and GPG keys:
![](https://img.php1.cn/3cd4a/1eebe/cd5/eec57030b649a106.webp)
点击“New SSH key”,将复制的密钥内容粘贴进Key的输入框,Title随便取:
![](https://img.php1.cn/3cd4a/1eebe/cd5/fb32005f2115b419.webp)
回到gitbush,测试输入: ssh -T git@github.com
![](https://img.php1.cn/3cd4a/1eebe/cd5/2d903861d5ad779c.png)
如果遇到 yes/no 的选项,输入yes。最后看到 “Hi ....”表示设置成功。