无法 push 到仓库?

报错如下 求助~

$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
To github.com:CodeCuber/larabbs.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:CodeCuber/larabbs.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.
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
最佳答案

我觉得可能是我创建仓库时勾选了生成readme文件,然后push时产生了冲突?

6年前 评论
讨论数量: 7

先git pull 一下

6年前 评论

@hereamI 我试了一下git pull还是没能解决
git pull之后在push的报错如下

vagrant@homestead:~/Code/larabbs$  git pull origin master
From github.com:CodeCuber/larabbs
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
        README.md
Please move or remove them before you can merge.
Aborting
vagrant@homestead:~/Code/larabbs$ git push -u origin master
To git@github.com:CodeCuber/larabbs.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:CodeCuber/larabbs.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

试了一下强制push 然后成功了 一切回归正常…… emmmm……

$ git push -u origin master -f
6年前 评论

我觉得可能是我创建仓库时勾选了生成readme文件,然后push时产生了冲突?

6年前 评论

@MGGJ 在入门教程的时候遇到过这个问题,github 新建的时候生成了 readme 文件,冲突导致。

6年前 评论

@LiLiKiLL 好吧 我觉得还是应当在书中注明一下这个问题,避免后人掉坑

6年前 评论

可以先 git init,然后如果还报错可以一次执行如下操作:
git add -A
git commit -m "init files"
git pull --rebase origin master
git push -u origin master

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!