图文链接:http://www.cnblogs.com/qcwblog/p/5709720.html
参考链接:http://blog.csdn.net/xuduorui/article/details/53612587
其他方法:http://www.cnblogs.com/ballwql/p/3462104.html
git remote -v
返回结果:
origin https://github.com/<username>/<repo>.git (fetch)
origin https://github.com/<username>/<repo>.git (push)
将push方式从https改为ssh:
1. git remote rm origin
2. git remote add origin git@github.com:<username>/<repo>.git
3. git push origin
-----------------------------------------------------------------------------------------------------
报错:
git push -u origin master
Permission denied (publickey).
生成公钥:
1、$ ssh-keygen -t rsa
返回: Generating public/private rsa key pair. Enter file in which to save the key (XXX/.ssh/id_rsa):公钥保存地址
Enter passphrase (empty for no passphrase):公钥生成的关键词,可以为空
......
2、将.ssh/id_rsa.pub文件中内容全部拷贝到github网站,成功后会受到key生成的邮件
3、$ eval 'ssh-agent'
$ ssh-add (passphrase) ——不知道为啥不行,不过每次输下passphrase也不太烦
4、$ ssh git@github.com 测试连通
返回:
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts. Enter passphrase for key 'XXX/.ssh/id_rsa': 输入关键词
...... 告诉你成功了