以后都用ssh来git
生成 SSH Key
设置git的用户名和邮箱
一般考虑用来管理github的仓库, 所以这里的用户名和邮件都建议设置成github账号对应的
1git config --global user.name "username"2git config --global user.email "example@gmail.com"有则备份, 无则跳过
先到
.ssh文件夹下面看看有没有已经生成的ssh key, 有的话要么直接拿来用, 要么以防万一备个份再重新生成ssh key(覆盖旧文件)- mac/linux 路径:
~/.ssh - windows 路径:
C:/User/username/.ssh
- mac/linux 路径:
生成 SSH Key
没错你又要再打一次邮箱地址1ssh-keygen -t rsa -C "example@gmail.com"然后连按三次回车, 密码为空就好了, 没事的. 看到一个奇怪的图形后说明OK了
测试github
1ssh git@github.com输入
yes, 你的电脑就认识github.com了, 也应该说明ssh没问题了
连接github
到https://github.com/settings/keys点new SSH Key, 复制.ssh/rsa_id.pub下的全文黏贴进去, 起个好点的名字, 保存.