git 官网下载地址(用迅雷下载更快,这算广告不,哈哈哈):http://git-scm.com/download/
生成ssh公钥
$ git config --global user.name "malong"
$ git config --global user.email "[email protected]"
$ ssh-keygen -t rsa -C "[email protected]"
按3个回车,密码为空,不需要输入密码
$ cat ~/.ssh/id_rsa.pub
然后将内容粘贴到github个人中心账户设置的ssh key 里面即可
一般就可以使用了,但可能由于服务端和客户端版本问题,可能会出现如下错误:”no matching key exchange method found by OpenSSH 7.0“ 。原因是客户端和服务器无法在密钥交换算法上达成一致,服务器只提供一个单一的方法diffie-hellman-group1-sha1,对这些故障的最佳解决方案是升级软件在另一端,但是如果不能升级另一端就只能禁用,具体操作如下:
在~/.ssh 下vim建一个config文件,如图
文件内容如下,host 为 github服务器ip
Host somehost.example.org KexAlgorithms +diffie-hellman-group1-sha1
好了,问题解决了,详见官方wiki
https://wiki.archlinux.org/index.php/Secure_Shell#no_matching_key_exchange_method_found_by_OpenSSH_7.0
网页的最下面有具体问题描述
解决中文乱码:
之前是用ubuntu开发提交代码为UTF-8的环境,迁移到windows就gitk查看历史会有乱码问题,可以在~/.gitconfig中加入
[gui]
encoding = utf-8
即可。