当前位置:   article > 正文

git 推送报错解决办法,Updates were rejected because the remote contains work that you do_windows提示:更新被拒绝,因为远程包含您所做的工作

windows提示:更新被拒绝,因为远程包含您所做的工作

一、报错信息

错误:无法将某些引用推送到...

提示:更新被拒绝,因为远程包含您所做的工作

  1. 16:04:07.007: [tlzf] git -c ... push --progress --porcelain origin refs/heads/master:refs/heads/master --set-upstream
  2. error: failed to push some refs to 'http://10.10.10.10/cesp/tlzf.git'
  3. hint: Updates were rejected because the remote contains work that you do
  4. To http://10.10.10.10/cesp/tlzf.git
  5. !    refs/heads/master:refs/heads/master    [rejected] (fetch first)
  6. hint: not have locally. This is usually caused by another repository pushing
  7. Done
  8. hint: to the same ref. You may want to first integrate the remote changes
  9. hint: (e.g., 'git pull ...') before pushing again.
  10. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

二、报错原因

gitlab上新建的项目包含README.md文件,远程库和本地库不一致造成的。

可以考虑,git新建项目时不建README.md文件

三、解决办法1

先拉一下,再推

git bash
cd D:/IdeaProjects/tlzf/tlzf #进入项目目录
先拉一下,允许不相关的历史记录
git pull origin master --allow-unrelated-histories

可以在idea直接操作

四、解决办法2

(未实践)

git pull --rebase origin master
git push -u origin master

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/987736
推荐阅读
相关标签
  

闽ICP备14008679号