一,下载git客户端 http://git-scm.com/download/
二 创建git账号信息
1 git config --global user.name "shulonghu"
git config --global user.email
650) this.width=650;" ?height="142" src="https://static.oschina.net/uploads/space/2017/0922/101424_zzpG_3692906.png" width="444" style="border:none;margin:auto;height:auto;" />
三 为Github账户设置 SSH Key
首先检查是否已生成密钥 cd ~/.ssh,ls如果有3个文件,则密钥已经生成,id_rsa.pub就是公钥
650) this.width=650;" ?height="86" src="https://static.oschina.net/uploads/space/2017/0922/101454_Wsmx_3692906.png" width="246" style="border:none;margin:auto;height:auto;" />
如果没有生成,那么通过$ ssh-keygen -t rsa -C “6215048wjl@163.com”来生成。
1)是路径确认,直接按回车存默认路径即可
2)直接回车键,这里我们不使用密码进行登录, 用密码太麻烦;
3)直接回车键
650) this.width=650;" ?height="282" src="https://static.oschina.net/uploads/space/2017/0922/101509_LshX_3692906.png" width="505" style="border:none;margin:auto;height:auto;" />
四 git提交仓库的常用命令顺序
git创建仓库的指令如下
git init //把这个目录变成git 可以管理的仓库
git add . //文件添加到仓库
git commit -m "注释说明" //把文件提仓库上
git remote add origin git@github.com:DragonTigerShu/文件名称 //关联远程仓库
git push -u origin master //把本地的库的所有内容库上
五 登录github账号
1 点击 new repository 新建本库。添加Rrpository name名称 添加描述信息 Description
点击创建 Create repository 完成显示版本库主页啦
2 之后获取远程版本库的地址,非常重要
3 然后打开Gitbash
切换到helloworld工程目录下,把远程版本库克隆到本地
有时候会传输超时。。就再试几次。。
650) this.width=650;" ?height="100" src="https://static.oschina.net/uploads/space/2017/0922/101534_UmoZ_3692906.png" width="513" style="border:none;margin:auto;height:auto;" />
4 之后ls -al查看工程目录 删除目录下创建的文件名称
650) this.width=650;" ?height="260" src="https://static.oschina.net/uploads/space/2017/0922/101549_mdBZ_3692906.png" width="513" style="border:none;margin:auto;height:auto;" />
5 git push origin mster 同步提交 这部非常重要
650) this.width=650;" ?height="407" src="https://static.oschina.net/uploads/space/2017/0922/101626_Mn3P_3692906.png" width="631" style="border:none;margin:auto;height:auto;" />
*注意 要是提交不上去出现报错
解决方案
1 首先执行下当前目录下 执行
git push -u origin master
650) this.width=650;" ?height="370" src="https://static.oschina.net/uploads/space/2017/0922/101653_O9Il_3692906.png" width="582" style="border:none;margin:auto;height:auto;" />
2 若依然没有解决目录下必须需要有README.md文件 然后通过合并的形式
执行 git pull --rebase origin master
650) this.width=650;" ?height="661" src="https://static.oschina.net/uploads/space/2017/0922/101705_zSO9_3692906.png" width="560" style="border:none;margin:auto;height:auto;" />
3 再次执行个git push -u origin master 完成上传工作 到github
650) this.width=650;" ?src="https://static.oschina.net/uploads/space/2017/0922/101719_3UFn_3692906.png" style="border:none;margin:auto;height:auto;" />
4 查看账号就看可以了.
本文出自 “凉秋暖思忆” 博客,请务必保留此出处http://9603537.blog.51cto.com/9593537/1967700
Github项目上传步骤
原文地址:http://9603537.blog.51cto.com/9593537/1967700