我这里直说实现的步骤,至于有些同学问安装什么的,就去先看安装教程吧!
1.建立git仓库 cd到你的本地项目根目录下,执行git命令
git init
2.将项目的所有文件添加到仓库中
git add .
如果是某一个文件就是 git add demo.txt
3.将add的文件commit到仓库
git commit -m "The source code first commit from to lzj" //最好加注释
4.拿到你创建的仓库的https地址,将本地的仓库关联到github上
git remote add origin https://github.com/hanhailong/CustomRatingBar
5.上传github之前,要先pull一下,执行如下命令:
git pull origin master
在这里有些童鞋会遇到问题报错信息比如:
这种的,这时不要捉急,因为这可能是用别人建好的仓库,而你本地不存在相关文件造成的。在这我执行命令如下:
git pull origin master --allow-unrelated-histories
进入编辑模式 随意添加时间信息和版本信息 比如: 2017/05/17 --version 1.0 保存退出即可
这一块解释详情请参考网上解释
The default behavior has changed since git 2.9:
"git merge" used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The command has been taught not to allow this by default, with an escape hatch --allow-unrelated-histories option to be used in a rare event that merges histories of two projects that started their lives independently.
See the git release changelog for more information.
You can use --allow-unrelated-histories to force the merge to happen.
6.pull完之后执行推送
git push -u origin master
6.pull完之后执行推送git push -u origin master
执行完后,如果没有异常,等待执行完就上传成功了,中间可能会让你输入Username和Password,你只要输入github的账号和密码就行了
-----The end!
-----The end!