本地实践---上传本地代码到Github

我这里直说实现的步骤,至于有些同学问安装什么的,就去先看安装教程吧!微笑微笑

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


执行完后,如果没有异常,等待执行完就上传成功了,中间可能会让你输入Username和Password,你只要输入github的账号和密码就行了

   -----The end!微笑








评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值