1、在ubuntu的终端安装git
sudo apt-get install git git-core
2、配置ubuntu系统的git账户
git config --global user.name "abc"
git config --global user.email abc@xxxx.com
3、生成密钥, 按三次回车,秘钥默认路径/root/.ssh/
ssh-keygen -t rsa -C "abc@xxxx.com" //邮箱同上
4,命令生成后,可以在/root/.ssh/文件夹下,找到公钥文件,
然后我们需要新建一个无后缀名的config文件,把里面加入如下内容,为了防止连接github失败。
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile /root/.ssh/id_rsa
Port 443
5、提交密钥,查看并复制秘钥
cat /root/.ssh/id_rsa.pub
打开 https://github.com/网页,登陆自己的账号,点击右上角的头像,选择Settings,找到左边的SSH keys,单击Add SSH keys,Title可以随意输入,复制密钥(cat /root/.ssh/id_rsa.pub),单击Add key并再次输入github的密码。
6、检验是否链接上了github
ssh -t git@github.com
//正常情况下,回显如下
PTY allocation request failed on channel 0
Hi plinx! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
7、提交,上传你的工程步骤
①、进入你的工程目录,输入git init,创建git仓库
②、git add [file],(file可以是文件名也可以是文件夹)
③、git commit -m ‘you introduction’
④、git remote add origin git@github.com:yourname/yourprojectname.git
⑤、git push -u origin master将你的文件上传到github
参考文档:
http://www.tuicool.com/articles/j2iqaa
http://blog.sina.com.cn/s/blog_63eb3eec0101cf6x.html
http://blog.csdn.net/keyboardota/article/details/7603630
http://www.cnblogs.com/plinx/archive/2013/04/08/3009159.html
http://www.xuebuyuan.com/zh-tw/2025269.html
http://www.xuebuyuan.com/651322.html
http://my.oschina.net/juwenz/blog/153350