git提交本地项目报错

这次我是想把写好的作业上传到github上,

  • 首先我在github上面新建了一个repository
  • 又在本地 git init建立了一个git仓库
  • 然后在git add commit后,使用命令
git remote add origin 远程仓库地址

没有消息。。。然后我就想起我老师说,没有消息就是好消息,然后我就想上传代码

 git push -u origin master 

发现报错了 ,报的是

To https://github.com/tjucaokun/photowall.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/tjucaokun/photowall.git'
hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

这我感觉应该是冲突了,所以我想pull一下,然后他又报了错

remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/tjucaokun/photowall * branch HEAD -> FETCH_HEAD fatal: refusing to merge unrelated histories 

上网搜索了一下,这是说这是两个不同的仓库,需要添加一句代码(如果你的分支是master)

git pull origin master ----allow-unrelated-histories

然后就完成了。

 [本文参考地址](http://blog.csdn.net/lindexi_gd/article/details/52554159)

 [欢迎关注我的github,给小白点个star哈~](https://github.com/tjucaokun)
 

转载于:https://www.cnblogs.com/ckcklalala/p/8551033.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值