前言
新换了一个电脑,需要进行很多内容的配置,在配置github的时候遇到了一些问题,每次都百度解决方案太麻烦,所以进行一次汇总。
步骤如下:
- 打开终端
-
会出现选型让你设置密码之类的,直接回车就行。ssh-keygen -t ed25519 -C "your_email@example.com"
一般有三个回车:- 提示您“Enter a file in which to save the key(输入要保存密钥的文件)”时,按 Enter 键。 这将接受默认文件位置。
- 设置密码 Enter passphrase (empty for no passphrase): [Type a passphrase]
- 确认密码 Enter same passphrase again: [Type passphrase again]
- 到这里已经生成ssh了,我们需要复制并配置到github之中。
或者使用命令行open ~/.ssh // 打开ssh文件所在位置,将里面的id_rsa.pub使用文本文件的形式打开并复制。
cat ~/.ssh/id_rsa.pub // 将需要复制的内容直接显示在终端之中进行复制。
- 打开 github.com/settings/pr… gthub的个人配置页面。选择
SSH and GPG keys
- 点击右上角的
NEW SSH KEY
将之前选中的内容复制下来就可以了。然后就可以愉快的clone代码了。
遇到的问题
- Please make sure you have the correct access rights and the repository exists
答: 这个原因是因为公钥出问题了.解决方案如下:- 通过
git config --list
打开电脑的git配置,查看知己的email和username是否正确,如果不正确,使用以下方式改正:
git config --global user.email "1239@qq.com"
git config --global user.name "yourname"
- 改正后,将
open ~/.ssh
打开文件位置,并将里面的内容清空。然后重新执行配置SSH的步骤。
- 通过