一、报错信息

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

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

16:04:07.007: [tlzf] git -c ... push --progress --porcelain origin refs/heads/master:refs/heads/master --set-upstream
error: failed to push some refs to 'http://10.10.10.10/cesp/tlzf.git'
hint: Updates were rejected because the remote contains work that you do
To http://10.10.10.10/cesp/tlzf.git
!    refs/heads/master:refs/heads/master    [rejected] (fetch first)
hint: not have locally. This is usually caused by another repository pushing
Done
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.

二、报错原因

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

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐