1. git下载安装地址:https://gitforwindows.org/

2.下载完,打开安装包,按照步骤安装,一直点 Next> (下一步) 就行了。
3. 打开Git Bash
4.生成ssh key
输入ssh-keygen -t rsa,然后连续按回车3次

5. 执行完上一步骤说明成功生成id_rsa和id_rsa.pub这两个文件。
id_rsa.pub为公钥,id_rsa为私钥,它们的都是隐藏文件。
① Linux和Max系统在 ~/.ssh下面。具体步骤如下:
查看它们的内容需要执行以下框中的命令
cd .ssh/

Is

执行完Is命令后,可以看到公钥和私钥。继续执行以下命令,可得到公钥的内容
cat id_rsa.pub

② Windows系统在C盘Documents and Settings/主机名/.ssh下面。具体步骤如下:
用Sublime或者其他编辑器打开C盘Documents and Settings/主机名/.ssh的文件夹。

如果打不开Documents and Settings文件,报错提示没有权限,点击改文件夹右键,点击 管理员取得所有权 即可。
6. 本地测试SSH Key是否添加成功
ssh -T 邮箱地址

出现上图则说明添加SSH Key成功
配置提交作者
$ git config --global user.name "[你的github名]"
$ git config --global user.email "[你的github邮箱]"
//如果希望在一个特定的项目使用不同的名称和email,就不要使用 --global 选项。
7. 修改SSH Key
查看SSH Key 文件列表
cd ~/.ssh
ls

删除ssh key :
cd ~
rm -rf .ssh
ssh-keygen -t rsa -C " 你的新邮箱地址 "

查看公钥
cat ~/.ssh/id_rsa.pub

最后把你的GitHub上的SSH keys 删了再重新添加一个就行了。
网友评论