从GitHub创建库

一、创建ssh key

通过SSH key绑定本地主机和GitHub,首先在本地产生一个SSH Key,并将key加入到GitHub帐户的公共Key中。

创建key命令如下:

ssh-keygen -t rsa -C "email" , 出现提示一路回车就可以了。

二、将Key 添加到GitHub

首先安装xclip,sudo apt-get install xclip

然后复制id_rsa.pub的内容

xclip - sel clip < /home/user_name/.ssh/id_rsa.pub

然后到GitHub页面,找到 Account Settings,点击左边的“SSH Keys”,点击“Add SSH Key”, 把“Key”粘贴到“Key”里面,点击“Add Key” 

三、测试

ssh -T git@github.com

如显示:

Hi ...! You've successfully authenticated, but GitHub does not provide shell access. 则表示安装成功

四、创建一个GitHub中的库

使用clone命令

如下: git clone git@github.com:lijiankou/prml.git   , 之后就可以使用了。

如果是第一次push,会出现如下情况:

”No refs in common and none specified; doing nothing.  
Perhaps you should specify a branch such as 'master'.  
fatal: The remote end hung up unexpectedly  
error: failed to push some refs to 'file:///xxxxxxx.git'  

使用下面命令即可:

git push origin master

相关资料:

http://wuyuans.com/2012/05/github-simple-tutorial/

https://help.github.com/articles/generating-ssh-keys

http://blog.csdn.net/feiniao1221/article/details/7516421

http://alexliyu.blog.163.com/blog/static/16275449620128675655428/

原文地址:https://www.cnblogs.com/lijiankou/p/3275899.html