github免密码push

生成 SSH Key:

1
2
#输入自己的github注册邮箱
ssh-keygen -t rsa -C "youremail@example.com"

提示直接回车
成功的话会在 ~/ 下生成 .ssh 文件夹

1
2
#打开 id_rsa.pub复制里面的 key
vim ~/.ssh/id_rsa.pub

到 github 上,进入 Account => Settings => SSH and GPG keys => New SSH key添加key

验证是否成功:

1
2
3
4
5
ssh -T git@github.com

#提示输入yes
#成功提示
Hi tianqixin! You've successfully authenticated, but GitHub does not provide shell access.

配置本地仓库(如果存在):

修改本地仓库中的 .git/config

把https格式url改为远程仓库地址
(如:url = git@github.com:YourAccount/YourRepo.git)

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!