Git已经逐步代替SVN成为版本管理工具,时势不可逆,也就边学边用了
一、 git用法官网已经有详细的中文文档和例子
https://git-scm.com/book/zh/v2
二、github使用
从github上clone代码下来,有HTTPS和SSH方式,如果没做任何的配置使用https是没问题的,但是使用SSH就会遇到这样一个问题
然而怎么解决呢
1、检查本地 ssh keys是否存在
ls -al ~/.ssh
如果目录下面没有id_rsa、id_rsa.pub文件,则表示key不存在,我的就没有 。
2、生成ssh key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3、将ssh key添加到ssh-agent
先确认ssh-agent是可用的 eval $(ssh-agent -s)
将ssh key添加到ssh-agent
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa)
4、将ssh key配置到github
复制key内容
$ clip < ~/.ssh/id_rsa.pub
配置key到github
登录github->选择Settings->SSH keys->New SSH key
测试ssh key的配置情况
$ ssh -t git@github.com
Warning: Permanently added the RSA host key for IP address ‘192.30.252.128’ to the list of known hosts.
PTY allocation request failed on channel 0
再次执行clone操作:
参考: http://www.linmuxi.com/2016/02/24/github-config-ssh/
这个链接排版更好