1、在windows下载安装git,网站如下
http://git-scm.com/download/
2、配置windows系统的git账户
$ git config --global user.name "abc"
$ git config --global user.email abc@xxxx.com
3、生成密钥, 按三次回车,注意记录秘钥默认路径(本电脑是 “/c/Users/shit/.ssh/id_rsa”):
$ ssh-keygen -t rsa -C "abc@xxxx.com" //邮箱同上
4,命令生成后,可以在 “/c/Users/shit/.ssh/id_rsa” 文件夹下,找到公钥文件,
然后我们需要新建一个无后缀名的config文件,把里面加入如下内容,为了防止连接github失败。
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile /root/.ssh/id_rsa
Port 443
5、提交密钥,查看并复制秘钥
$ cat /c/Users/shit/.ssh/id_rsa
打开 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