- 设置Git 的user name和email
- 创建SSH Key
ssh-keygen -t rsa -C "<你的邮箱>"

系统提示输入文件保存位置等信息,默认连续敲三次回车即可获得定义密码和名字,生成的 SSH key 文件保存在中
~/.ssh/id_rsa.pub
- 获取Key
cat ~/.ssh/id_rsa.pub
- 将终端拿到的ssh密钥复制添加到github上



- 利用 git remote set-url 将HTTPS协议换成SSH协议
git remote -v #先查看当前链接方式
> origin https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin https://github.com/USERNAME/REPOSITORY.git (push)
在github查看你的URL

- 在终端输入
git remote set-url origin git@github.com:username/repository.git
- 查看是否生效
git remote -v
# Verify new remote URL
> origin git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin git@github.com:USERNAME/REPOSITORY.git (push)